Fix allow_mail_archived_partner causing system notifications to send emails

This commit is contained in:
Kristof Bernaert
2026-01-26 02:37:29 +01:00
parent bc4557b473
commit 02a172f582
3 changed files with 84 additions and 16 deletions
@@ -52,12 +52,54 @@ class AccountInvoiceSend(models.TransientModel):
"""
Pass context to mail composer to allow archived partners.
"""
_logger.debug("Passing context to allow archived partners")
_logger.debug("=== _get_composer_values ===")
_logger.debug(f"Passing context to allow archived partners")
# FIX: Changed include_archived_partner to include_archived_partners (plural)
return super(
AccountInvoiceSend,
self.with_context(
active_test=False,
include_archived_partner=True,
include_archived_partners=True, # FIXED: plural 's'
mail_notify_force=True,
)
)._get_composer_values(res_ids, template)
)._get_composer_values(res_ids, template)
def action_send_and_print(self):
"""
Override send action to add logging and ensure context is passed.
"""
_logger.debug("=== ACCOUNT.INVOICE.SEND action_send_and_print ===")
_logger.debug(f"Context before send: {dict(self.env.context)}")
_logger.debug(f"Partner IDs: {self.partner_ids.ids}")
# Ensure context is passed when calling action
result = super(
AccountInvoiceSend,
self.with_context(
active_test=False,
include_archived_partners=True,
mail_notify_force=True,
force_email=True, # Ensure mail_thread.py recognizes this
mark_invoice_as_sent=True, # Ensure mail_thread.py recognizes this
)
).action_send_and_print()
_logger.debug("Email send action completed")
return result
# Also override the regular send action if it exists
def action_send(self):
"""
Override send action (without print) to ensure context.
"""
_logger.debug("=== ACCOUNT.INVOICE.SEND action_send ===")
return super(
AccountInvoiceSend,
self.with_context(
active_test=False,
include_archived_partners=True,
mail_notify_force=True,
force_email=True,
mark_invoice_as_sent=True,
)
).action_send()