雲端儲存空間

雲端儲存整合允許將:doc:`聊天欄 <../../productivity/discuss/chatter>`和電子郵件附件儲存在:ref:`Google Cloud <cloud-storage/google>`或:ref:`Microsoft Azure <cloud-storage/microsoft>`平台上,而不是資料庫的伺服器上。

此模組可用於防止大型檔案上傳至資料庫伺服器或從資料庫伺服器下載,或當資料庫需要更多資料儲存空間時使用。

備註

  • 由 Odoo 生成的檔案(例如銷售訂單)和文件/簽名應用程式檔案始終儲存在資料庫的伺服器上。

  • 資料庫的儲存限制取決於其託管解決方案:

    • Odoo 雲端版:100 GB

    • Odoo.sh:

      • 共享託管:512 GB

      • 專用託管:4 TB

    • 離線安裝:受現有基礎設施限制。

Google Cloud

首先,註冊並登入 Google Cloud

服務帳戶

  1. 在 Google Cloud 控制台上開啟導航側邊欄,然後前往:menuselection:IAM 與管理 --> 服務帳戶 --> 建立服務帳戶

  2. 定義:guilabel:服務帳戶名稱,按一下:guilabel:建立並繼續,然後按一下:guilabel:完成

    建立 Google Cloud 服務帳戶
  3. 記下服務帳戶的:guilabel:Email,因為在:ref:`cloud storage bucket configuration <cloud-storage/google/bucket>`時會用到。

  4. 按一下:icon:fa-ellipsis-v (Actions) 按鈕,然後選擇:guilabel:Manage keys

    存取「Manage keys」動作
  5. 前往:menuselection:Add key --> Create new key,選擇:guilabel:JSON`作為:guilabel:`Key type,然後按一下:guilabel:Create。請妥善保存下載的 JSON 檔案,其中包含金鑰。在:ref:`configuring Odoo <cloud-storage/google/odoo>`時會用到。

    建立 Google Cloud 服務帳戶的 JSON 金鑰

雲端儲存貯體

  1. 在 Google Cloud 控制台開啟導覽側邊欄,然後前往:menuselection:Cloud Storage --> Buckets --> Create

  2. 輸入符合 bucket naming guidelines 的貯體名稱並記下來,因為在:ref:`configuring Odoo <cloud-storage/google/odoo>`時會用到。

  3. 依需求配置貯體,完成後按一下:guilabel:Create

    建立貯體
  4. 按一下:icon:fa-ellipsis-v (More actions) 按鈕,然後選擇:guilabel:Edit access

    存取 Google Cloud 儲存貯體的「Edit access」動作
  5. 按一下:guilabel:Add principal,並在:guilabel:`New principals`欄位中貼上服務帳戶的電子郵件。

  6. 在:guilabel:Cloud Storage`區段下選擇:guilabel:`Storage Admin`作為:guilabel:`Role,然後按一下:guilabel:Save

    新增主體至 Google Cloud 儲存貯體

Odoo 配置

  1. Install:guilabel:`Cloud Storage Google`模組。

  2. 開啟:guilabel:Settings`應用程式,並在導覽側邊欄中選擇:guilabel:`Cloud Storage

  3. 選擇:guilabel:Google Cloud Storage`作為:guilabel:`Cloud Storage Provider for new attachments

  4. 輸入:ref:previously set <cloud-storage/google/bucket>`的:guilabel:`Google Bucket Name

  5. Google Service Account Key 旁邊按一下 Upload your file,然後選擇:ref:下載的 JSON 檔案 <cloud-storage/google/service>

  6. 為要儲存在 Google Cloud 上的附件設定:guilabel:Minimum File Size (bytes)

Microsoft Azure

首先,註冊並登入 Microsoft Azure

應用程式註冊

  1. 在 Microsoft Azure 入口網站上,搜尋:guilabel:App registrations 服務並開啟。

  2. 按一下:guilabel:New registration,輸入應用程式:guilabel:Name,在:guilabel:Supported account types 下選擇:guilabel:Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant),然後按一下:guilabel:Register

    註冊 Microsoft Azure 應用程式
  3. 記下:guilabel:Application (client) ID 和:guilabel:Directory (tenant) ID,因為在:ref:配置 Odoo <cloud-storage/microsoft/odoo> 時會用到。

  4. 在:guilabel:Client credentials 旁邊按一下:guilabel:Add a certificate or secret,按一下:guilabel:New client secret,然後按一下:guilabel:Add

    重要

    基於安全考量,將:guilabel:Expires 欄位保留為 180 days (6 months) 或選擇較短的到期時間。在密鑰到期之前,必須加入新的用戶端密鑰,並使用新值更新:ref:Odoo 的配置 <cloud-storage/microsoft/odoo>

  5. 複製用戶端密鑰的:guilabel:Value 並妥善保存。在:ref:配置 Odoo <cloud-storage/microsoft/odoo> 時會用到。

    為 Microsoft Azure 應用程式加入密鑰

儲存體帳戶

  1. 搜尋:guilabel:Storage accounts 服務,開啟並按一下:guilabel:Create

  2. 在:guilabel:Resource group 欄位下方按一下:guilabel:Create new,輸入:guilabel:Name,然後按一下:guilabel:OK

  3. 輸入唯一的:guilabel:Storage account name 並記下,因為在:ref:配置 Odoo <cloud-storage/microsoft/odoo> 時會用到。

  4. 依需要配置儲存體帳戶,完成後按一下:guilabel:Review + create,然後按一下:guilabel:Create

    建立 Microsoft Azure 儲存體帳戶

容器

  1. 開啟您的儲存體帳戶資源,例如透過搜尋其名稱,然後在導覽側欄的:guilabel:資料儲存體`下選取:guilabel:`容器

  2. 輸入:guilabel:名稱,記下此名稱,因為在:ref:設定 Odoo <cloud-storage/microsoft/odoo> 時會用到,然後按一下:guilabel:建立

    建立 Microsoft Azure 儲存體容器

資源共用

  1. 在儲存體帳戶的導覽側欄上,選取:guilabel:設定`下的:guilabel:`資源共用 (CORS)

  2. 建立第一個 CORS Blob 服務規則:

    • 允許的來源*

    • 允許的方法GET

    • 允許的標頭Content-Type

    • 公開的標頭Content-Type

    • 最長存在時間0

  3. 建立第二個 CORS Blob 服務規則,然後按一下:guilabel:儲存

    • 允許的來源*

    • 允許的方法PUT

    • 允許的標頭content-type,x-ms-blob-type

    • 公開的標頭content-type,x-ms-blob-type

    • 最長存在時間0

    建立 Microsoft Azure 儲存體帳戶 CORS 規則

角色指派

  1. 在儲存體帳戶的導覽側欄上選取:guilabel:存取控制 (IAM),然後按一下:guilabel:加入`並選取:guilabel:`加入角色指派

  2. 搜尋:guilabel:儲存體 Blob 資料參與者,然後按一下:guilabel:下一步

    備註

    若要移除不必要的 delete 權限,請建立:ref:自訂角色 <cloud-storage/microsoft/custom>,然後搜尋自訂角色的名稱。

  3. 按一下 Select members,輸入 先前註冊的應用程式 的名稱,選取它,然後按一下 Select

  4. 按一下 Review + assign 兩次。

    將成員加入容器
自訂角色

備註

此步驟為**選用**。然而,移除 delete 權限可防止任何設法存取雲端儲存憑證的人刪除檔案。

  1. 開啟您的訂閱資源,例如透過搜尋其名稱,在導覽側邊欄中選取 Access control (IAM),按一下 Add 並選取 Add custom role

  2. 選取 JSON 分頁並按一下 Edit。複製下方的程式碼,在 assignableScopes 下加入您的 subscription-id,並視需要變更 roleName`(`Custom role),貼上它,然後按一下 Save

{
    "properties": {
        "roleName": "Custom role",
        "description": "",
        "assignableScopes": [
            "/subscriptions/subscription-id"
        ],
        "permissions": [
            {
                "actions": ["Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey/action"],
                "notActions": [],
                "dataActions": ["Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read", "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action"],
                "notDataActions": []
            }
        ]
    }
}

Odoo 配置

  1. 安裝 Cloud Storage Azure 模組。

  2. 開啟:guilabel:Settings`應用程式,並在導覽側邊欄中選擇:guilabel:`Cloud Storage

  3. 選取 Azure Cloud Azure 作為 Cloud Storage Provider for new attachments

  4. 輸入:

  5. 設定 Minimum File Size (bytes),以便將附件儲存在 Microsoft Azure 上。