Fix allow_mail_archived_partner causing system notifications to send emails
This commit is contained in:
@@ -13,21 +13,6 @@ class MailTemplate(models.Model):
|
||||
that sets:
|
||||
context['mail_notify_force'] = True
|
||||
|
||||
This prevents system notifications from inheriting your relaxed rules.
|
||||
"""
|
||||
if self.model in ["sale.order", "account.move"] and self.env.context.get("mail_notify_force"):
|
||||
return super(
|
||||
MailTemplate,from odoo import models
|
||||
|
||||
|
||||
class MailTemplate(models.Model):
|
||||
_inherit = "mail.template"
|
||||
|
||||
def generate_email(self, res_ids, fields=None):
|
||||
"""
|
||||
Only allow archived partners when *explicitly* sending through a flow
|
||||
that sets context['mail_notify_force'] = True.
|
||||
|
||||
This prevents system notifications from inheriting your relaxed rules.
|
||||
"""
|
||||
if self.model in ["sale.order", "account.move"] and self.env.context.get("mail_notify_force"):
|
||||
@@ -40,10 +25,3 @@ class MailTemplate(models.Model):
|
||||
).generate_email(res_ids, fields)
|
||||
|
||||
return super().generate_email(res_ids, fields)
|
||||
self.with_context(
|
||||
active_test=False,
|
||||
include_archived_partners=True
|
||||
)
|
||||
).generate_email(res_ids, fields)
|
||||
|
||||
return super().generate_email(res_ids, fields)
|
||||
|
||||
Reference in New Issue
Block a user