diff --git a/allow_mail_archived_partner/models/account_move_send.py b/allow_mail_archived_partner/models/account_move_send.py index 5fc6f2b..1d222d7 100755 --- a/allow_mail_archived_partner/models/account_move_send.py +++ b/allow_mail_archived_partner/models/account_move_send.py @@ -7,7 +7,7 @@ from odoo import models, api, fields class AccountInvoiceSend(models.TransientModel): _inherit = "account.invoice.send" - # Allow archived partners to stay visible in the wizard + # Allow archived partners to remain selectable partner_ids = fields.Many2many( 'res.partner', string='Recipients', @@ -34,17 +34,19 @@ class AccountInvoiceSend(models.TransientModel): def action_send_and_print(self): """ - Explicitly rebuild recipients from partner_ids to avoid - Odoo silently skipping send when archived partners are used. + Explicitly set email_to on the wizard record. + This is REQUIRED for account.invoice.send. """ self.ensure_one() - # Build email_to explicitly emails = [p.email for p in self.partner_ids if p.email] if not emails: _logger.warning("No recipient emails found; skipping send.") return {'type': 'ir.actions.act_window_close'} + # 🔥 THIS is the critical line + self.email_to = ",".join(emails) + return super( AccountInvoiceSend, self.with_context( @@ -53,6 +55,5 @@ class AccountInvoiceSend(models.TransientModel): mail_notify_force=True, force_email=True, mark_invoice_as_sent=True, - email_to=",".join(emails), ) ).action_send_and_print()