地址自動完成

Odoo 與 Google Places API 整合,允許地址自動完成。當您開始輸入地址時,系統會提供建議位置清單,減少手動錯誤並節省時間。

聯絡人表單上的地址自動完成。

重要

使用 Google Places API 可能需要`向 Google 付款 <https://mapsplatform.google.com/pricing/>`_。

Google Places API 配置

要使用 Google 進行地址自動完成,您必須先:ref:啟用 API <address_autocomplete/enable-api> 並:ref:建立所需的憑證 <address_autocomplete/generate_api_key>

啟用 Google Places API

要啟用 Google Places API,請按照以下步驟操作:

  1. 前往 Google Cloud 控制台

  2. 建立登入 Google 帳戶。

  3. 在左上角,按一下:guilabel:Select a project。然後在:guilabel:Select a resource`彈出視窗中,建立:guilabel:`New Project

    小訣竅

    若您已建立專案,但想切換到不同的專案,請按一下左上角所選專案的名稱。然後在:guilabel:`Select a resource`彈出視窗中,手動選取專案。若所需的專案已預設選取,請繼續下一步。

  4. 開啟:icon:fa-bars (Navigation menu)`側邊面板,然後前往:menuselection:`APIs and services –> Enabled APIs and services

  5. 按一下:icon:fa-plus Enable APIs and services

  6. 搜尋:guilabel:`Places API`並選取它。

    重要

    請勿啟用:guilabel:Places API (New),因為 Odoo 尚未支援。

  7. 按一下:guilabel:Enable

  8. 完成驗證流程。

建立 API 憑證

:ref:`專案建立完成且 Places API 已啟用 <address_autocomplete/enable-api>`後,建立 API 憑證。請依照以下步驟進行:

  1. 開啟專案的:icon:fa-bars (Navigation menu)`側邊面板,然後前往:menuselection:`APIs and services –> Credentials

  2. 按一下:icon:fa-plus Create credentials ,然後選取:guilabel:API key

  3. 在:guilabel:Create API key`面板中,輸入:guilabel:`Name

  4. 在:guilabel:Select API restrictions`下拉式選單中,若專案中設定了多個 API,請指定此金鑰可存取的 API。確保已選取:guilabel:`Places API,然後按一下:guilabel:OK

  5. 按一下:guilabel:Create

備註

在:guilabel:`Application restrictions`下,可限制 API 金鑰僅允許來自特定網站、IP 位址或應用程式的請求。

重要

請安全儲存您的 API 金鑰,切勿公開分享。

Odoo 配置

API 金鑰產生後,將 Odoo 資料庫連線到 Google Places API。請依照以下步驟進行:

  1. 前往**設定應用程式**。

  2. 前往:guilabel:`Integrations`區段。

  3. 啟用:guilabel:Google Address Autocomplete,然後按一下:guilabel:Save

  4. 返回:guilabel:`Integrations`部分,然後將您的:ref:`Google Places API key <address_autocomplete/generate_api_key>`貼上到專用欄位中。

  5. 按一下:guilabel:儲存