From bdea6c5efb12fce349400ba72dbf56210a4652d1 Mon Sep 17 00:00:00 2001 From: sergio-teruel Date: Mon, 11 Nov 2024 14:08:11 +0100 Subject: [PATCH] [FIX] account_invoice_mass_sending: Users have extra notifications when the invoice has sent by the job TT51673 --- account_invoice_mass_sending/models/account_move.py | 2 ++ .../wizards/account_invoice_send.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/account_invoice_mass_sending/models/account_move.py b/account_invoice_mass_sending/models/account_move.py index f7c70fedcc4..c23aca96bc3 100644 --- a/account_invoice_mass_sending/models/account_move.py +++ b/account_invoice_mass_sending/models/account_move.py @@ -43,6 +43,8 @@ def _send_invoice_individually(self, template=None): { "active_model": self._name, "active_ids": self.ids, + "discard_logo_check": True, + "account_invoice_mass_sending": True, } ) wiz = self.env["account.invoice.send"].with_context(**wiz_ctx).create({}) diff --git a/account_invoice_mass_sending/wizards/account_invoice_send.py b/account_invoice_mass_sending/wizards/account_invoice_send.py index 986150d9c93..428d1a44908 100644 --- a/account_invoice_mass_sending/wizards/account_invoice_send.py +++ b/account_invoice_mass_sending/wizards/account_invoice_send.py @@ -1,6 +1,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, models +from odoo import _, api, models class AccountInvoiceSend(models.TransientModel): @@ -48,3 +48,12 @@ def enqueue_invoices(self): } ) return notification + + @api.onchange("invoice_ids") + def _compute_composition_mode(self): + """Force send as mass_mail although this module sends each invoice one by one + to avoid extra notificactions""" + if not self.env.context.get("account_invoice_mass_sending", False): + return super()._compute_composition_mode() + for wizard in self: + wizard.composer_id.composition_mode = "mass_mail"