From 4d7f944d631c6297ae62d8bff5be2d806619f7ab Mon Sep 17 00:00:00 2001 From: Kristof Bernaert Date: Mon, 26 Jan 2026 03:10:59 +0100 Subject: [PATCH] Fix allow_mail_archived_partner causing system notifications to send emails --- .../models/account_move_send.py | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/allow_mail_archived_partner/models/account_move_send.py b/allow_mail_archived_partner/models/account_move_send.py index d904b06..a37c4cd 100755 --- a/allow_mail_archived_partner/models/account_move_send.py +++ b/allow_mail_archived_partner/models/account_move_send.py @@ -7,37 +7,23 @@ from odoo import models, api, fields class AccountInvoiceSend(models.TransientModel): _inherit = "account.invoice.send" - # OVERRIDE THE FIELD DEFINITION - partner_ids = fields.Many2many( - 'res.partner', - string='Recipients', - help='Contacts of the invoice that will receive the email.', - context={'active_test': False}, - check_company=True, - ) @api.model def default_get(self, fields): - _logger.info("=== ACCOUNT.INVOICE.SEND DEFAULT_GET ===") - res = super().default_get(fields) - + active_ids = self.env.context.get('active_ids', []) - if active_ids: moves = self.env['account.move'].with_context( active_test=False ).browse(active_ids) - - partner_ids = [] - for move in moves: - if move.partner_id: - partner_ids.append(move.partner_id.id) - - if partner_ids: - res['partner_ids'] = [(6, 0, partner_ids)] - _logger.info(f"SET partner_ids: {res['partner_ids']}") - + + partners = moves.mapped('partner_id').filtered(lambda p: p.email) + + if partners: + res['partner_ids'] = [(6, 0, partners.ids)] + res['email_to'] = ", ".join(partners.mapped('email')) + return res def action_send_and_print(self):