Skip to content

[16.0] account_invoice_transmit_peppol: Speedup and indepotent - #14

Open
lmignon wants to merge 2 commits into
edido-eu:16.0from
acsone:16.0-account_invoice_transmit_peppol-one-transfer-job
Open

[16.0] account_invoice_transmit_peppol: Speedup and indepotent#14
lmignon wants to merge 2 commits into
edido-eu:16.0from
acsone:16.0-account_invoice_transmit_peppol-one-transfer-job

Conversation

@lmignon

@lmignon lmignon commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@lmignon
lmignon force-pushed the 16.0-account_invoice_transmit_peppol-one-transfer-job branch 4 times, most recently from 876f66f to 7ca0da0 Compare January 21, 2026 14:05
Comment on lines +15 to +16
not self.is_move_sent
and not self.invoice_exported

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow resending in case of delivery failure

Suggested change
not self.is_move_sent
and not self.invoice_exported
not invoice_export_confirmed

priority=40,
channel="root.invoice_transmit.peppol",
)._transmit_invoice_by_peppol()
if not invoice._is_transmissible_by_peppol():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe generate a first job calling


to update invoice_export_confirmed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a delayable method on the invoice itself to check its status...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds a good idea if invoice_export is True. That would be a limited number of case

* 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
@lmignon
lmignon force-pushed the 16.0-account_invoice_transmit_peppol-one-transfer-job branch from 7ca0da0 to 9437113 Compare January 22, 2026 09:21
@sbejaoui

Copy link
Copy Markdown
Contributor

@jbaudoux , @lmignon ,

please review my last commit

@lmignon
lmignon marked this pull request as ready for review May 22, 2026 06:21
Comment on lines 21 to 48
@@ -18,20 +28,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)

@lmignon lmignon May 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pattern I like and implement now in my code is to create a method returning a delayable receiving job_options as arguments and call delay on the delayable returned by the method. In this way, it can be extended to change or fine tune the job_options according to a specific project need...

Suggested change
def _batch_transmit_invoice_by_peppol(self):
"""Mass sending by peppol
"""
for invoice in self:
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._enqueue_transmit_invoice_by_peppol(description=description).delay()
result.append(description)
return "\n".join(result)
def _enqueue_transmit_invoice_by_peppol(self, **job_options):
self.ensure_one()
job_options = job_options.copy()
job_options.setdefault("identity_key", identity_exact")
job_options.setdefault("priority", 40)
job_options.setdefault("channel", "root.invoice_transmit.peppol")
delayable = self.delayable(**job_options)
return delayable._transmit_invoice_by_peppol()
``

…oices

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
@sbejaoui
sbejaoui force-pushed the 16.0-account_invoice_transmit_peppol-one-transfer-job branch from 0ceb3c5 to 7e00771 Compare May 22, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants