使用Google生成产品图片

拥有产品图片对于很多原因都很有用。但是,如果要为很多产品分配图片,这会非常耗时。

幸运的时,通过在Odoo数据库中配置 谷歌自定义搜索 API,基于产品条码的图片搜索是非常高效的。

配置

在Odoo数据库中使用 谷歌自定义搜索 是非常高效的。

Note

谷歌账户允许用户每天选择100张免费图片。如果需要更高数量的图片,需要升级计费。

谷歌API仪表板

  1. 要使用谷歌自定义搜索API,必须首先生成谷歌自定义搜索API凭证。然后,使用谷歌账户登录。

  2. 从这里,选择(或创建)一个API项目来保存凭证。首先,为项目起一个 memorable

  3. 从左侧栏中选择凭证选项,然后点击 Create Credentials,并选择 API密钥从下拉菜单中。

    谷歌云平台上的API & 服务页面。
  4. 复制并保存 你的API key。稍后,将使用此密钥。当密钥已复制并保存时,请点击 Close ,以删除弹出窗口。

    创建的API密钥弹出窗口。
  5. 在此页面中,搜索 ` Custom Search API`,并选择它。

    谷歌云平台上的搜索栏,包含 "Custom Search API"。
  6. 从 “Custom Search API” 页,点击 启用 ,以启用该API。

    "Custom Search API" 页,高亮了启用按钮。

谷歌可编程搜索仪表板

  1. 要使用 谷歌可编程搜索 ,必须首先生成谷歌可编程搜索API凭证。然后,使用谷歌账户登录。

    谷歌可编程搜索引擎页面,包含 Get Started 开始按钮。
  2. On the Create a new search engine form, fill out the name of the search engine, along with what the engine should search, and be sure to enable Image Search and SafeSearch.

    Create new search engine form that appears with search engine configurations.
  3. Validate the form by clicking Create.

  4. Doing so reveals a new page with the heading: Your new search engine has been created.

    The Your New Search Engine Has Been Created page that appears with copy code.
  5. From this page, click Customize to open the Overview ‣ Basic page. Then, copy the ID in the Search engine ID field. This ID is needed for the Odoo configuration.

    Basic overview page with search engine ID field.

Odoo

  1. In the Odoo database, go to the Settings app and scroll to the Integrations section. From here, check the box beside Google Images. Then, click Save.

    The Google Images setting in the Odoo Settings app page.
  2. Next, return to the Settings app, and scroll to the Integrations section. Then, enter the API Key and Search Engine ID in the fields beneath the Google Images feature.

  3. 点击 保存

Product images in Odoo with Google Custom Search API

Adding images to products in Odoo can be done on any product or product variant. This process can be completed in any Odoo application that provides access to product pages (e.g. Sales app, Inventory app, etc.).

Below is a step-by-step guide detailing how to utilize the Google Custom Search API to assign images to products in Odoo using the Odoo Sales application:

  1. Navigate to the Products page in the Sales app (Sales app ‣ Products ‣ Products). Or, navigate to the Product Variants page in the Sales app (Sales app ‣ Products ‣ Product Variants).

  2. Select the desired product that needs an image.

    Note

    Only products (or product variants) that have a barcode, but not an image, are processed.

    If a product with one or more variants is selected, each variant that matches the aforementioned criteria is processed.

  3. Click the Action ⚙️ (gear) icon on the product page, and select Get Pictures from Google Images from the menu that pops up.

    The Get Pictures from Google Images option from the Action drop-down menu in Odoo.
  4. On the pop-up window that appears, click Get Pictures.

    The pop-up that appears in which the user should click Get Picture in Odoo Sales.
  5. Once clicked, the image(s) will appear incrementally.

    Note

    Only the first 10 images are fetched immediately. If you selected more than 10, the rest are fetched as a background job.

    The background job processes about 100 images in a minute. If the quota authorized by Google (either with a free or a paid plan) is reached, the background job puts itself on hold for 24 hours. Then, it will continue where it stopped the day before.