From 9437113825477d08aa88bc31773c991b9ef58e8f Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Wed, 21 Jan 2026 14:14:26 +0100 Subject: [PATCH 1/2] [IMP] account_invoice_transmit_peppol: Speedup job creation * Uses the invoice's name into the job description in place of the dislay_name since the last one consume a lot of ressources to be computed * Makes the delayed method idempotent --- .../models/account_move.py | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/account_invoice_transmit_peppol/models/account_move.py b/account_invoice_transmit_peppol/models/account_move.py index 87f6085..2c3f7d4 100644 --- a/account_invoice_transmit_peppol/models/account_move.py +++ b/account_invoice_transmit_peppol/models/account_move.py @@ -8,6 +8,14 @@ class AccountMove(models.Model): _inherit = "account.move" + def _is_transmissible_by_peppol(self): + """Check if the invoice can be sent by peppol""" + self.ensure_one() + return ( + not self.invoice_export_confirmed + and self.transmit_method_code == "peppol" + ) + def _batch_transmit_invoice_by_peppol(self): """Mass sending by peppol @@ -18,20 +26,27 @@ def _batch_transmit_invoice_by_peppol(self): """ result = [] for invoice in self: - description = _( - "Generating invoice for peppol sending: %(name)s", - name=invoice.display_name, - ) - invoice.with_delay( - description=description, - identity_key=identity_exact, - priority=40, - channel="root.invoice_transmit.peppol", - )._transmit_invoice_by_peppol() + if not invoice._is_transmissible_by_peppol(): + description = _( + "Invoice already sent to peppol: %(name)s", + name=invoice.name, + ) + else: + description = _( + "Generating invoice for peppol sending: %(name)s", + name=invoice.name, + ) + invoice.with_delay( + description=description, + identity_key=identity_exact, + priority=40, + channel="root.invoice_transmit.peppol", + )._transmit_invoice_by_peppol() result.append(description) return "\n".join(result) def _transmit_invoice_by_peppol(self): """Sending by peppol""" + invoices = self.filtered(lambda p: p._is_transmissible_by_peppol()) invoices = self._transmit_invoice("peppol") return invoices.peppol_export_invoice() From 7e00771a32328336a2babb59dd93f375d02698fc Mon Sep 17 00:00:00 2001 From: Souheil Bejaoui Date: Thu, 21 May 2026 11:00:22 +0200 Subject: [PATCH 2/2] [IMP] account_invoice_transmit_peppol: prevent resending exported invoices avoid retransmitting invoices through Peppol when `invoice_export` is already set `invoice_export_confirmed` may be updated later by the status check cron, so relying only on this field can allow the same document to be sent again before the confirmation is synchronized --- .../models/account_move.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/account_invoice_transmit_peppol/models/account_move.py b/account_invoice_transmit_peppol/models/account_move.py index 2c3f7d4..906f787 100644 --- a/account_invoice_transmit_peppol/models/account_move.py +++ b/account_invoice_transmit_peppol/models/account_move.py @@ -11,10 +11,12 @@ class AccountMove(models.Model): def _is_transmissible_by_peppol(self): """Check if the invoice can be sent by peppol""" self.ensure_one() - return ( - not self.invoice_export_confirmed - and self.transmit_method_code == "peppol" - ) + if self.transmit_method_code != "peppol": + return False + if self.invoice_exported and not self.invoice_export_confirmed: + # Already sent but confirmation not yet synced + return False + return not self.invoice_export_confirmed def _batch_transmit_invoice_by_peppol(self): """Mass sending by peppol @@ -48,5 +50,5 @@ def _batch_transmit_invoice_by_peppol(self): def _transmit_invoice_by_peppol(self): """Sending by peppol""" invoices = self.filtered(lambda p: p._is_transmissible_by_peppol()) - invoices = self._transmit_invoice("peppol") + invoices = invoices._transmit_invoice("peppol") return invoices.peppol_export_invoice()