Fix allow_mail_archived_partner causing system notifications to send emails
This commit is contained in:
@@ -41,15 +41,23 @@ class AccountInvoiceSend(models.TransientModel):
|
||||
_logger.error(f"🔥 Partner IDs: {self.partner_ids.ids}")
|
||||
_logger.error(f"🔥 Current context: {dict(self.env.context)}")
|
||||
|
||||
# CRITICAL: Pass ALL required context flags
|
||||
# CRITICAL: Get the actual partner email for logging
|
||||
if self.partner_ids:
|
||||
for partner in self.partner_ids:
|
||||
_logger.error(f"🔥 Wizard partner: {partner.id} - {partner.name}, active={partner.active}, email={partner.email}")
|
||||
|
||||
# Call parent with context AND ensure partner_ids are passed
|
||||
# We need to pass partner_ids to the message_post call
|
||||
return super(
|
||||
AccountInvoiceSend,
|
||||
self.with_context(
|
||||
active_test=False, # For res.partner searches
|
||||
include_archived_partners=True, # For mail_thread.py
|
||||
mail_notify_force=True, # For mail_thread.py
|
||||
force_email=True, # Already present
|
||||
mark_invoice_as_sent=True, # Already present
|
||||
active_test=False,
|
||||
include_archived_partners=True,
|
||||
mail_notify_force=True,
|
||||
force_email=True,
|
||||
mark_invoice_as_sent=True,
|
||||
# Add partner_ids to context so mail_thread can access them
|
||||
invoice_partner_ids=self.partner_ids.ids if self.partner_ids else [],
|
||||
)
|
||||
).action_send_and_print()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user