雲端儲存空間¶
雲端儲存整合允許將: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。
服務帳戶¶
在 Google Cloud 控制台上開啟導航側邊欄,然後前往:menuselection:
IAM 與管理 --> 服務帳戶 --> 建立服務帳戶。定義:guilabel:
服務帳戶名稱,按一下:guilabel:建立並繼續,然後按一下:guilabel:完成。
記下服務帳戶的:guilabel:
Email,因為在:ref:`cloud storage bucket configuration <cloud-storage/google/bucket>`時會用到。按一下:icon:
fa-ellipsis-v(Actions) 按鈕,然後選擇:guilabel:Manage keys。
前往:menuselection:
Add key --> Create new key,選擇:guilabel:JSON`作為:guilabel:`Key type,然後按一下:guilabel:Create。請妥善保存下載的 JSON 檔案,其中包含金鑰。在:ref:`configuring Odoo <cloud-storage/google/odoo>`時會用到。
雲端儲存貯體¶
在 Google Cloud 控制台開啟導覽側邊欄,然後前往:menuselection:
Cloud Storage --> Buckets --> Create。輸入符合 bucket naming guidelines 的貯體名稱並記下來,因為在:ref:`configuring Odoo <cloud-storage/google/odoo>`時會用到。
依需求配置貯體,完成後按一下:guilabel:
Create。
按一下:icon:
fa-ellipsis-v(More actions) 按鈕,然後選擇:guilabel:Edit access。
按一下:guilabel:
Add principal,並在:guilabel:`New principals`欄位中貼上服務帳戶的電子郵件。在:guilabel:
Cloud Storage`區段下選擇:guilabel:`Storage Admin`作為:guilabel:`Role,然後按一下:guilabel:Save。
Odoo 配置¶
開啟:guilabel:
Settings`應用程式,並在導覽側邊欄中選擇:guilabel:`Cloud Storage。選擇:guilabel:
Google Cloud Storage`作為:guilabel:`Cloud Storage Provider for new attachments。輸入:ref:
previously set <cloud-storage/google/bucket>`的:guilabel:`Google Bucket Name。在 Google Service Account Key 旁邊按一下 Upload your file,然後選擇:ref:
下載的 JSON 檔案 <cloud-storage/google/service>。為要儲存在 Google Cloud 上的附件設定:guilabel:
Minimum File Size (bytes)。
Microsoft Azure¶
首先,註冊並登入 Microsoft Azure。
應用程式註冊¶
在 Microsoft Azure 入口網站上,搜尋:guilabel:
App registrations服務並開啟。按一下:guilabel:
New registration,輸入應用程式:guilabel:Name,在:guilabel:Supported account types下選擇:guilabel:Accounts in any organizational directory (Any Microsoft Entra ID tenant - Multitenant),然後按一下:guilabel:Register。
記下:guilabel:
Application (client) ID和:guilabel:Directory (tenant) ID,因為在:ref:配置 Odoo <cloud-storage/microsoft/odoo>時會用到。在: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>。複製用戶端密鑰的:guilabel:
Value並妥善保存。在:ref:配置 Odoo <cloud-storage/microsoft/odoo>時會用到。
儲存體帳戶¶
搜尋:guilabel:
Storage accounts服務,開啟並按一下:guilabel:Create。在:guilabel:
Resource group欄位下方按一下:guilabel:Create new,輸入:guilabel:Name,然後按一下:guilabel:OK。輸入唯一的:guilabel:
Storage account name並記下,因為在:ref:配置 Odoo <cloud-storage/microsoft/odoo>時會用到。依需要配置儲存體帳戶,完成後按一下:guilabel:
Review + create,然後按一下:guilabel:Create。
容器¶
開啟您的儲存體帳戶資源,例如透過搜尋其名稱,然後在導覽側欄的:guilabel:
資料儲存體`下選取:guilabel:`容器。輸入:guilabel:
名稱,記下此名稱,因為在:ref:設定 Odoo <cloud-storage/microsoft/odoo>時會用到,然後按一下:guilabel:建立。
資源共用¶
在儲存體帳戶的導覽側欄上,選取:guilabel:
設定`下的:guilabel:`資源共用 (CORS)。建立第一個 CORS Blob 服務規則:
允許的來源:
*允許的方法:
GET允許的標頭:
Content-Type公開的標頭:
Content-Type最長存在時間:
0
建立第二個 CORS Blob 服務規則,然後按一下:guilabel:
儲存:允許的來源:
*允許的方法:
PUT允許的標頭:
content-type,x-ms-blob-type公開的標頭:
content-type,x-ms-blob-type最長存在時間:
0
角色指派¶
在儲存體帳戶的導覽側欄上選取:guilabel:
存取控制 (IAM),然後按一下:guilabel:加入`並選取:guilabel:`加入角色指派。搜尋:guilabel:
儲存體 Blob 資料參與者,然後按一下:guilabel:下一步。備註
若要移除不必要的
delete權限,請建立:ref:自訂角色 <cloud-storage/microsoft/custom>,然後搜尋自訂角色的名稱。按一下 Select members,輸入 先前註冊的應用程式 的名稱,選取它,然後按一下 Select。
按一下 Review + assign 兩次。
自訂角色¶
備註
此步驟為**選用**。然而,移除 delete 權限可防止任何設法存取雲端儲存憑證的人刪除檔案。
開啟您的訂閱資源,例如透過搜尋其名稱,在導覽側邊欄中選取 Access control (IAM),按一下 Add 並選取 Add custom role。
選取 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 配置¶
安裝 Cloud Storage Azure 模組。
開啟:guilabel:
Settings`應用程式,並在導覽側邊欄中選擇:guilabel:`Cloud Storage。選取 Azure Cloud Azure 作為 Cloud Storage Provider for new attachments。
輸入:
Azure Account Name 欄位中的 儲存體帳戶名稱;
Azure Container Name 欄位中的 容器名稱;
Azure Tenant ID 欄位中的 目錄(租用戶)ID;
Azure Client ID 欄位中的 應用程式(用戶端)ID;以及
Azure Client Secret 欄位中的 用戶端密碼值。
設定 Minimum File Size (bytes),以便將附件儲存在 Microsoft Azure 上。