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

时间:2018-01-07 18:09:36

标签: 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.

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

哪些模板可以修改? 有没有办法禁用这个内部通知全球?

2 个答案:

答案 0 :(得分:1)

您可以在模块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则不执行任何操作。

答案 1 :(得分:-1)

您不需要开发任何东西。这是Odoo内部的用户配置。

Settings -> Technical -> Subtypes

致谢