模型、模組及應用程式

「模型」是用以決定資料庫邏輯結構,以及數據如何儲存、整理及操作。換言之,模型是可以連接其他表格的資料表。一個模型通常代表一個業務概念,例如 銷售單聯絡人產品 等。

模組及應用程式則包含各種元素,例如模型、檢視畫面、數據檔案、網站控制器、靜態網站數據等。

備註

所有應用程式都是模組。較大的獨立模組通常稱為應用程式(app),而其他模組則通常會是這些應用程式的附加組件。

建議功能

利用 Studio 建立新模型或應用程式時,你可選擇加入多達 14 項功能,以加快建立過程。這些功能將不同元素集於一身,包括欄位、預設設定,以及通常用作提供標準功能的檢視畫面。多數上述功能可在日後加入,但在一開始時加入能令模型建立過程更容易。此外,某些情況下,這些功能可以互動,增強實用性。

Example

啟用 圖片管道階段 功能後才建立模型,會在 看板檢視模式 的卡片版面中,加入相關圖片。

看板檢視畫面中圖片及管道階段功能組合

聯絡方法

選擇 聯絡資料 後, 表單檢視畫面 會新增一個連結至 聯絡人 模型及當中兩個 相關欄位電話電郵 )的 多對一欄位聯絡人 欄位也會加入至 列表檢視畫面 中,而 地圖檢視畫面 也會被啟動。

Example

表單檢視畫面中的聯絡人資料功能

使用者分配

選擇 指派使用者 會在 表單檢視畫面 中新增一個連結至 聯絡人 模型的 多對一欄位 ,而其 範圍 會設定為 共用使用者未設定 ,以只允許選擇 內部使用者 。此外,系統會使用 many2one_avatar_user 小工具去顯示使用者的頭像。 負責人 欄位也會加入 列表檢視畫面

Example

表單檢視畫面的使用者分配功能

日期及日曆

選擇 日期及日曆 會在 表單檢視畫面 中新增一個 日期欄位 ,並會啟動 日曆檢視畫面

日期範圍及甘特圖

選擇 日期範圍及甘特圖 ,會在 表單檢視畫面 中加入兩個 日期欄位 並放在一起,分別透過 daterange (日期範圍)小工具,去設定開始日期及結束日期。此操作亦會啟動 甘特圖檢視畫面

管道階段

選擇 管道階段 會啟動 看板檢視畫面 ,並新增 優先級別看板狀態 等數個欄位,以及 新增進行中完成 三個階段。 管道狀態列看板狀態 欄位會加入至 表單檢視畫面顏色 欄位會新增至 列表檢視畫面

備註

管道階段 功能可以容後才加入。

標籤

選擇 標籤 會在 表單列表 檢視畫面中,新增一個 標籤欄位 ,並會建立一個已預先配置存取權限的 標籤 模型。

圖片

選擇 圖片 會在 表單檢視畫面 的右上角,新增一個 圖片欄位

備註

圖片 功能可以容後才加入。

資料行

選擇 資料行 :會在 表單檢視畫面 中,在 分頁 組件內新增一個 資料行欄位

備註

選擇 備註 會在 表單檢視畫面 中,新增一個使用表單全部寬度的 HTML 欄位

金錢價值

選擇 金錢價值 會在 表單列表 檢視畫面中,新增一個 金錢價值欄位 ,同時亦會啟動 圖形樞紐分析表 檢視畫面。

備註

貨幣 欄位已加入檢視畫面及設為隱藏。

公司

選擇 公司 會在 表單列表 檢視畫面中,新增一個連結至 公司 模型的 多對一欄位

備註

此功能只會在多公司環境中有用。

自訂排序

選擇 自訂排序 會在 列表檢視畫面 中新增一個拖曳把手圖示,用於手動將記錄重新排序。

Example

列表视图中的自定义排序功能

聊天視窗

选择:guilabel:`聊天窗口`会向:ref:`Form view <studio/views/general/form>`添加聊天窗口功能(发送信息、记录笔记和计划活动)。

備註

:guilabel:`聊天窗口`功能可以之后添加。

Example

表单视图中的聊天窗口功能

正在封存

选择:guilabel:归档`会向:ref:`studio/views/general/form and :ref:`studio/views/multiple-records/list`视图添加:guilabel:`归档`动作,并在默认情况下,从搜索和视图中隐藏已存档的记录。

导出和导入自定义项

When you do any customization with Studio, a new module named studio_customization is added to your database. You can export this module as a ZIP file using the Studio Export function. The module can then be imported into another Odoo database. This may be useful, for example, when setting up a new module or for training purposes.

備註

以這種方式匯出及匯入自訂功能,而非使用 標準的 Odoo 匯出及匯入 功能,表示資料是以合乎邏輯的方式匯入。例如,如果模組包含客戶記錄及銷售單,會先建立客戶,因為建立銷售單是需要有客戶資料。

Export customizations

To export customizations, click the (Toggle Studio) button on the main Odoo dashboard, then Export, then either:

Configure data to export

To select specific models to export, click New on the Studio Export screen, then start typing the name of the relevant model or select it from the list.

小訣竅

Click Preset to see a list of all models in your database with records that have been modified using Studio and all custom models created using Studio. To configure one of these models for export, click on the model to open it and make the required changes.

Tick the following options as relevant:

  • Demo: if the exported records should be considered as demo data when imported.

  • Attachments: if attachments related to exported records should be included in the export.

  • Updatable: if the exported records should be able to be updated during a module update.

If necessary, edit the Domain to determine which of the model’s records should be exported. To do so, click the Edit Domain button or (Modify filter) then Edit Domain, as appropriate. Proceed to make any required changes.

After configuring a model for export, click Studio Export to return to the main screen. To download a ZIP file with the customizations for all the listed models, click Export.

備註

It is not necessary to select one or more models as all listed models will be included in the export. To remove a model from the export, select it and click the Actions button then Delete.

In the Studio Export window:

  • leave the checkboxes unticked to export only the customizations done with Studio.

  • tick Include Data to include data from the selected models in the export.

  • tick Include Demo Data to include data from the selected models that is flagged as demo data. Ticking this option also ticks Include Data.

Click the Export button to download the ZIP file.

Choosing to export both data and demo data

Import customizations

警告

Before importing, make sure the destination database is on the same Odoo version and contains the same apps and modules as the source database. Studio does not add the underlying modules as dependencies of the exported module.

To import and install Studio customizations in another Odoo database:

  1. Connect to the destination database.

  2. Click the (Toggle Studio) button on the main Odoo dashboard, then Import.

  3. Upload the exported ZIP file. If demo data should be imported, tick Load demo data.

  4. Click Install.