将 Google 日历与 Odoo 同步

将 Google 日历与 Odoo 同步,可同时查看和管理两个平台上的会议(双向更新)。这种整合有助于安排日程,从而避免错过会议。

在Google中设定

选择(或创建)一个项目

创建一个新的 Google API 项目并启用 Google 日历。首先,访问 `Google API 控制台<https://console.developers.google.com>`_并登录 Google 账户。

備註

如果是首次访问此页面,Google 将提示用户输入国家/地区并同意服务条款。请从下拉列表中选择一个国家,并同意 ToS(服务条款)

接下来,单击:guilabel:选择项目`并选择(或创建)一个 API 项目,以便在其中配置 OAuth 和存储凭据。单击 :guilabel:`新建项目

创建一个新的API项目来存储凭据。

小訣竅

为 API 项目起一个清晰的名称,例如“Odoo Sync”,以便您轻松找到它。

启用 Google 日历 API

现在,点击左侧菜单中的 启用 API 和服务。如果没有出现 搜索栏,请再次选择 启用 API 和服务

在API项目中启用API和服务。

然后,使用搜索栏搜索 Google 日历 API,并从搜索结果中选择 Google 日历 API。点击 启用

启用谷歌日历API。

创建凭据

要将 Google 日历连接到 Odoo,需要 客户 ID客户密钥。这是 Google 控制台的最后一步。首先点击左侧菜单中的 证书。然后,单击 创建凭据,并选择 OAuth 客户端 ID,Google 将打开创建凭据的指南。

创建 OAuth 客户 ID 下,为 应用类型 字段选择 网站申请,并为 名称 键入 我的 Odoo 数据库

  • 经授权 JavaScript Origins 部分,单击 + 添加 URI 并键入公司的 Odoo 完整 URL (统一资源定位器) 地址。

  • 经授权重新定向 URIs 部分,单击 + 添加 URI,然后键入公司的 Odoo URL(统一资源定位符) 地址,后面跟上`/google_account/authentication`。最后,点击 创建

添加授权的 JavaScript 起源和授权的重定向 URI。

将显示 客户 ID客户密钥,将其复制到记事本中。

设置Odoo

找到 客户 ID客户密钥 后,打开 Odoo 数据库并转到 设置 ‣ 常规设置 ‣ 整合 ‣ Google 日历。选中 Google 日历 旁边的复选框。

常规设置中的谷歌日历复选框。

接下来,将 Google 日历 API 证书页面中的 客户 ID客户密钥 复制并粘贴到 Google 日历 复选框下方的相应字段中。然后,单击 保存

在 Odoo 中同步日历

最后,打开 Odoo 中的 日历 应用程序,点击 Google 同步按钮,将 Google 日历与 Odoo 同步。

点击Odoo日历中的谷歌同步按钮来将谷歌日历与Odoo同步。

備註

首次将 Google 日历与 Odoo 同步时,页面将重定向到 Google 账户。在那里,选择应具有访问权限的 电子邮件账户,然后选择 继续`(如果应用程序未经验证),最后选择 :guilabel:`继续`(允许传输数据)

给 Odoo 访问 Google 日历的权限。

现在,Odoo 日历已成功与 Google 日历同步!

警告

Odoo 强烈建议在测试数据库和测试电子邮件地址(不用于任何其他目的)上测试 Google 日历同步,然后再尝试将所需的 Google 日历与用户的生产数据库同步。

一旦用户将 Google 日历与 Odoo 日历同步后:

  • 在 Odoo 中创建活动会导致 Google 向所有参与者发送邀请。

  • 在 Odoo 中删除活动会导致 Google 向所有参与者发送取消通知。

  • 将联系人添加到活动会导致 Google 向所有参与者发送邀请。

  • 从活动中删除联系人会导致 Google 向所有参与者发送取消通知。

Events can be created in Google Calendar without sending a notification by selecting Don’t Send when prompted to send invitation emails.

Troubleshoot sync

There may be times when the Google Calendar account does not sync correctly with Odoo. Sync issues can be seen in the database logs.

In these cases, the account needs troubleshooting. A reset can be performed using the Reset Account button, which can be accessed by navigating to Settings app ‣ Manage Users. Then, select the user to modify the calendar, and click the Calendar tab.

Reset buttons highlighted on the calendar tab of the user.

Next, click Reset Account under the correct calendar.

Reset options

The following reset options are available for troubleshooting Google calendar sync with Odoo:

Google calendar reset options in Odoo.

User’s Existing Events:

  • Leave them untouched: no changes to the events.

  • Delete from the current Google Calendar account: delete the events from Google Calendar.

  • Delete from Odoo: delete the events from the Odoo calendar.

  • Delete from both: delete the events from both Google Calendar and Odoo calendar.

Next Synchronization:

  • Synchronize only new events: sync new events on Google Calendar and/or Odoo calendar.

  • Synchronize all existing events: sync all events on Google Calendar and/or Odoo calendar.

Click Confirm after making the selection to modify the user’s events and the calendar synchronization.

Google OAuth FAQ

At times there can be misconfigurations that take place, and troubleshooting is needed to resolve the issue. Below are the most common errors that may occur when configuring the Google Calendar for use with Odoo.

Production vs. testing publishing status

Choosing Production as the Publishing Status (instead of Testing) displays the following warning message:

OAuth is limited to 100 sensitive scope logins until the OAuth consent screen is verified. This may require a verification process that can take several days.

To correct this warning, navigate to the Google API Platform. If the Publishing Status is In Production, click Back to Testing to correct the issue.

No test users added

If no test users are added to the OAuth consent screen, then an Error 403: access_denied populates.

403 Access Denied Error.

To correct this error, return to the OAuth consent screen, under APIs & Services, and add test users to the app. Add the email to be configured in Odoo.

Application Type

When creating the credentials (OAuth Client ID and Client Secret), if Desktop App is selected for the Application Type, an Authorization Error appears (Error 400:redirect_uri_mismatch).

Error 400 Redirect URI Mismatch.

To correct this error, delete the existing credentials, and create new credentials, by selecting Web Application for the Application Type.

Then, under Authorized redirect URIs, click ADD URI, and type: https://yourdbname.odoo.com/google_account/authentication in the field, being sure to replace yourdbname in the URL with the real Odoo database name.

小訣竅

Ensure that the domain (used in the URI: https://yourdbname.odoo.com/google_account/authentication) is the exact same domain as configured in the web.base.url system parameter.

Access the web.base.url by activating developer mode, and navigating to Settings app ‣ Technical header menu ‣ Parameters section ‣ System Parameters.