电子邮件模板

电子邮件模板是已保存的电子邮件,可重复用于从数据库发送电子邮件。用户无需重复编写相同的文本,即可发送高质量的邮件。

根据具体情况创建不同的模板,可让用户为正确的受众选择正确的信息。这样可以提高信息的质量和客户的整体参与率。

注解

Email templates in Odoo use QWeb or XML, which allows for editing emails in their final rendering, making customizations more robust, without having to edit any code whatsoever. This means that Odoo can use a Graphical User Interface (GUI) to edit emails, which edits the backend code. When the received email is read by the end user’s program different formatting and graphics will appear in the final form of it.

开发者模式 中访问电子邮件模板,方法是导航至 设置应用程序 ‣ 技术菜单 ‣ 电邮 ‣ 电邮模版

编辑电子邮件模板

在使用电子邮件模板时,可以使用*powerbox*功能。该功能可以直接编辑电子邮件模板中的格式和文本,还可以添加链接、按钮、预约选项或图片。

Additionally, the XML/HTML code of the email template can be edited directly, via the </> icon.

Dynamic placeholders (text that references fields within Odoo to auto-fill information on the template) are available for the Email Configuration fields, the Subject, and the Language.

Powerbox

*powerbox*功能是一个丰富的文本编辑器,具有各种格式、布局和文本选项。它还可用于在电子邮件模板中添加 XML/HTML 功能。在电子邮件模板正文中键入正斜线 /,即可激活此功能。

在电子邮件模板正文中键入正斜线 `/`时,会出现一个下拉菜单,其中包含以下选项:

基础模块

  • 标题 1:大节标题。

  • 标题 2:中标题。

  • 标题 3:小标题。

  • 文本:段落块。

  • 项目符号列表: 创建一个简单的项目符号列表。

  • 编号列表: 创建带编号的列表。

  • 清单:使用清单跟踪任务。

  • 表格: 插入表格。

  • 切换方向:切换文本的方向。

  • 分隔符:插入水平线分隔符。

  • 引用:添加引用块部分。

  • 代码:添加代码部分。

  • 预约:添加特定预约。

  • 日历:安排预约。

导航

  • 链接:添加链接。

  • 按钮:添加按钮。

Medias

  • 图片:插入图片。

小技巧

要使用这些选项中的任何一个,请从 powerbox 下拉菜单中点击所需的功能。要使用文本相关选项(如 标题 1转换方向 等)格式化现有文本,请选中文本,然后键入激活键(正斜杠)`/`,并从下拉菜单中选择所需的选项。

电子邮件模板中的 Powerbox 功能。

XML/HTML 代码编辑器

要访问电子邮件模板的 XML/HTML 编辑器,首先输入 开发者模式。然后,单击模板右上角的 </> 图标,继续编辑 XML/HTML。要返回标准文本编辑器,请再次单击 </> 图标。

电子邮件模板中的 HTML 编辑器。

警告

应谨慎访问 XML/HTML 编辑器,因为这是模板的后台代码。编辑代码可能会导致电子邮件模板立即中断或在升级数据库时中断。

动态占位符

*动态占位符*引用 Odoo 数据库中的某些字段,以便在电子邮件模板中生成独特的数据。

Example

许多公司喜欢用个性化的客户信息来定制电子邮件,以吸引眼球。在 Odoo 中,可以通过插入动态占位符引用模型中的字段来实现这一目的。例如,可以在来自:guilabel:销售订单`模型上的:guilabel:`客户`字段的电子邮件中引用客户姓名。该字段的动态占位符为: `{{ object.partner_id }}

Dynamic placeholders are encoded to display fields from within the database. Dynamic placeholders can only be used in the fields present in the Email Configuration tab, the Subject of the email, and the Language.

Dynamic placeholders can be used with the following fields on an email template:

  • Subject (Content tab)

  • From (Email Configuration tab)

  • To (Emails) (Email Configuration tab)

  • To (Partners) (Email Configuration tab)

  • CC (Email Configuration tab)

  • Reply-To (Email Configuration tab)

  • Language (Advanced Settings tab)

The Dynamic Placeholder Generator, which is the last tab on the email template, creates placeholders for the aforementioned fields. Dynamic placeholders may also be inserted in the HTML code, but this task is out of the scope of Odoo Support.

To use the Dynamic Placeholder Generator, navigate to the Dynamic Placeholder Generator tab. Select the field that the dynamic placeholder should reference using the Field drop-down menu. Should a Sub-Model or Sub-Field need to be specified, set those by selecting the corresponding drop-down menu. These fields should be set automatically after setting the Field, although in some instances these fields will remain empty. The dynamic placeholder will appear in the Placeholder Expression field. Copy and paste the placeholder expression into the appropriate field in the tabs of the email template, as listed in the bulleted list above.

注解

:guilabel:`字段’、:guilabel:`子模型’和:guilabel:`子字段’的每个独特组合都会创建不同的动态占位符。将其想象为正在创建的字段的组合。

To search the available fields, simply click the drop-down menu next to Field and select one, or click Search More to select from all of the available fields for the model that the email template is created for.

小技巧

These fields can also be accessed in developer mode. On a contact form (or other relevant form in Odoo), navigate to the information that should be referenced in the dynamic placeholder, and hover over the field name. A box of backend information will reveal itself with the specific Odoo Field name in the backend. Search for this field in the Field drop-down menu in the email template.

Backend information box of fields on a model.

警告

定制电子邮件模板不属于 Odoo 支持的范围。

默认回复电子邮件模板

在电子邮件模板的 电子邮件配置 选项卡下,有一个 回复至 字段。使用此模板群发邮件时,可在此字段中添加回复重定向到的电子邮件地址。

小技巧

A Add multiple email addresses by adding a comma , between the addresses or dynamic placeholders.

模板上的回复字段

:guilabel:`回复至`字段**仅**用于群发邮件(批量发送邮件)。几乎所有具有列表视图选项的 Odoo 应用程序都可以群发邮件。

要群发电子邮件,请在 列表 视图中,选中要发送电子邮件的记录旁边的方框,单击 操作 按钮(由 ⚙️(齿轮) 图标表示),然后从 操作 下拉菜单中选择所需的电子邮件选项。电子邮件选项可能因特定列表视图和应用程序而异。

如果可以发送电子邮件,则会弹出邮件撰写器窗口,其中的值可以定义和自定义。在可批量发送电子邮件的页面上,例如在 CRM 应用程序的 客户 页面上,:guilabel:`操作`按钮上将显示此选项。此操作会在整个 Odoo 数据库中进行。

群发邮件模式下的电子邮件撰写器,高亮显示“回复至”。

事务性电子邮件和相应的 URL

在 Odoo 中,多个活动可触发自动电子邮件发送。这些邮件被称为*事务性电子邮件*,有时包含重定向到 Odoo 数据库的链接。

默认情况下,数据库生成的链接使用系统参数中定义的动态 web.base.url 键。有关详细信息,请参阅 系统参数

如果未安装 Website 应用程序,web.base.url 键将始终是用于生成所有链接的默认参数。

重要

web.base.url 键只能有一个单一的值,这意味着在多网站或多公司数据库环境中,即使每个网站都有一个特定的域名,为共享文档而生成的链接(或事务性电子邮件中的链接)也可能保持不变,无论哪个网站/公司与发送电子邮件/文档相关。

Example

如果 web.base.url 系统参数的 等于 https://www.mycompany.com,并且 Odoo 中有两个不同的公司,其网站 URL 也不同:https://www.mycompany2.com`和 `https://www.mycompany1.com,无论哪家公司发送文件或电子邮件,Odoo 创建的用于共享文件或发送交易电子邮件的链接都来自`https://www.mycompany.com`域。

情况并非总是如此,因为有些 Odoo 应用程序(例如*电子商务*)在数据库中与*网站*应用程序建立了链接。在这种情况下,如果为网站定义了特定域,电子邮件模板中生成的 URL 就会使用公司相应网站上定义的域。

Example

当客户在 Odoo 电子商务 网站上购物时,订单与该网站建立了链接。因此,发送给客户的确认电子邮件中的链接会使用该特定网站的域名。

注解

使用 文档 应用程序共享的文档将**始终**使用`web.base.url`键,因为共享的文档与任何特定网站无关。这意味着,无论从哪家公司共享,URL 始终是相同的(web.base.url 键值)。这是一个已知的限制。

For more information about how to configure domains, check out the domain name documentation.

更新电子邮件模板中的翻译

在 Odoo 中,电子邮件模板会为数据库中的所有用户自动翻译所安装的所有语言。无需更改翻译。不过,如果出于特殊原因需要更改某些翻译,也是可以做到的。

警告

与代码中的任何修改一样,如果翻译更改操作不当(例如,导致语法错误的修改),可能会破坏模板,从而使模板显示为空白。

要编辑翻译,首先进入 开发者模式。然后,在电子邮件模板上点击 编辑 按钮,再点击语言按钮,该按钮以当前使用的语言首字母表示(例如,:guilabel:`EN`表示英语)。

编辑模板语言。

注解

如果数据库中没有安装和激活多种语言,或者用户没有管理访问权限,则不会出现语言按钮。

弹出一个窗口,显示数据库中安装的不同语言。在弹出窗口中可以编辑翻译。完成所需更改后,点击 保存 按钮保存更改。

预约已确认的模板正文翻译。

注解

编辑翻译时,数据库中的默认语言设置将以**粗体**显示。