地址自動完成¶
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,請按照以下步驟操作:
前往 Google Cloud 控制台。
在左上角,按一下:guilabel:
Select a project。然後在:guilabel:Select a resource`彈出視窗中,建立:guilabel:`New Project。小訣竅
若您已建立專案,但想切換到不同的專案,請按一下左上角所選專案的名稱。然後在:guilabel:`Select a resource`彈出視窗中,手動選取專案。若所需的專案已預設選取,請繼續下一步。
開啟:icon:
fa-bars(Navigation menu)`側邊面板,然後前往:menuselection:`APIs and services –> Enabled APIs and services。按一下:icon:
fa-plusEnable APIs and services。搜尋:guilabel:`Places API`並選取它。
重要
請勿啟用:guilabel:
Places API (New),因為 Odoo 尚未支援。按一下:guilabel:
Enable。完成驗證流程。
建立 API 憑證¶
:ref:`專案建立完成且 Places API 已啟用 <address_autocomplete/enable-api>`後,建立 API 憑證。請依照以下步驟進行:
開啟專案的:icon:
fa-bars(Navigation menu)`側邊面板,然後前往:menuselection:`APIs and services –> Credentials。按一下:icon:
fa-plusCreate credentials ,然後選取:guilabel:API key。在:guilabel:
Create API key`面板中,輸入:guilabel:`Name。在:guilabel:
Select API restrictions`下拉式選單中,若專案中設定了多個 API,請指定此金鑰可存取的 API。確保已選取:guilabel:`Places API,然後按一下:guilabel:OK。按一下:guilabel:
Create。
備註
在:guilabel:`Application restrictions`下,可限制 API 金鑰僅允許來自特定網站、IP 位址或應用程式的請求。
重要
請安全儲存您的 API 金鑰,切勿公開分享。
Odoo 配置¶
API 金鑰產生後,將 Odoo 資料庫連線到 Google Places API。請依照以下步驟進行: