Fix allow_mail_archived_partner causing system notifications to send emails

This commit is contained in:
Kristof Bernaert
2026-01-26 01:20:08 +01:00
parent 659b5890a7
commit 8cafb4a908
3 changed files with 52 additions and 29 deletions
@@ -1,14 +1,22 @@
from odoo import models, api
class AccountMoveSend(models.TransientModel):
_inherit = "account.move.send"
class AccountMoveSendWizard(models.TransientModel):
_inherit = "account.move.send.wizard"
@api.model
def _get_default_mail_partner_ids(self, move, mail_template, mail_lang):
"""
The invoice 'Send by Email' wizard uses this to compute partner_ids (To:).
We must disable active_test here to include archived partners.
Allow archived partners when sending invoices via
the 'Send by Email' wizard.
"""
wiz = self.with_context(active_test=False, include_archived_partners=True)
return super(AccountMoveSend, wiz)._get_default_mail_partner_ids(move, mail_template, mail_lang)
# Force archived partners to be visible ONLY in this context
wiz = self.with_context(
active_test=False,
include_archived_partners=True,
)
return super(
AccountMoveSendWizard,
wiz
)._get_default_mail_partner_ids(move, mail_template, mail_lang)