python - Odoo 10 - 创建销售订单或发票时的电子邮件通知

标签 python xml odoo-10 odoo

当用户 A 创建销售订单且用户 B 作为客户经理时,将发送以下电子邮件:

Dear User B,
You have been assigned to the sales order SO-0058.
<View sales order>
Powered by Odoo.

创建发票时会发送类似的电子邮件。

这个模板可以在哪里修改? 有什么方法可以全局禁用此内部通知吗?

最佳答案

您可以在模块 mail、文件夹 views、文件 mail_templates.xml 中找到该通知。

您要查找的模板的 XML ID 是 message_user_assigned

在同一模块、文件夹models、文件mail_thread.py中,有发送该通知的操作:

@api.multi
def _message_auto_subscribe_notify(self, partner_ids):
    """ Notify newly subscribed followers of the last posted message.
        :param partner_ids : the list of partner to add as needaction partner of the last message
                                (This excludes the current partner)
    """
    if not partner_ids:
        return

    if self.env.context.get('mail_auto_subscribe_no_notify'):
        return

    # send the email only to the current record and not all the ids matching active_domain !
    # by default, send_mail for mass_mail use the active_domain instead of active_ids.
    if 'active_domain' in self.env.context:
        ctx = dict(self.env.context)
        ctx.pop('active_domain')
        self = self.with_context(ctx)

    for record in self:
        record.message_post_with_view(
            'mail.message_user_assigned',
            composition_mode='mass_mail',
            partner_ids=[(4, pid) for pid in partner_ids],
            auto_delete=True,
            auto_delete_message=True,
            parent_id=False, # override accidental context defaults
            subtype_id=self.env.ref('mail.mt_note').id)

在您的情况下会执行此操作,因为 sale.orderaccount.invoice 模型继承自 mail.thread:

class AccountInvoice(models.Model):
    _name = "account.invoice"
    _inherit = ['mail.thread']
    _description = "Invoice"
    _order = "date_invoice desc, number desc, id desc"

我不建议您删除该_inherit。我认为最好覆盖 _message_auto_subscribe_notify 方法来检查事件模型,如果这是 sale.orderaccount.invoice 则不执行任何操作.

关于python - Odoo 10 - 创建销售订单或发票时的电子邮件通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48140103/

相关文章:

php - 如何在 Flex 中创建和访问带有属性的 xml

javascript - Odoo - 如何翻译 javascript 文件中的字符串

javascript - 如何从 Odoo 10 中的 JS 函数更新 One2many 字段?

python - sklearn 聚类 : Fastest way to determine optimal number of cluster on large data sets

python - python如何自然支持大整数并高效?

python - 如何配置 sqlalchemy 以正确存储表情符号?

odoo - 根据组过滤记录 [Odoo]

python - 在没有 pip 的情况下安装 matplotlib 和 numpy

java - 找不到以下类: Names of layouts

java - 在MapReduce中解析XML文件