-
-
Notifications
You must be signed in to change notification settings - Fork 56
[19.0][FIX] edi_queue_oca: propagate failed jobs to exchanges #321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from . import edi_exchange_record | ||
| from . import edi_exchange_type | ||
| from . import edi_backend | ||
| from . import queue_job |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright 2026 Camptocamp SA | ||
| # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). | ||
|
|
||
| from odoo import models | ||
|
|
||
|
|
||
| class QueueJob(models.Model): | ||
| _inherit = "queue.job" | ||
|
|
||
| def write(self, vals): | ||
| result = super().write(vals) | ||
| if vals.get("state") == "failed": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Direct SQL updates executed by the queue_job runner will bypass this logic https://github.com/OCA/queue/blob/19.0/queue_job/jobrunner/runner.py#L217 In the situation where the number of retries exceeds the maximum allowed, the job is marked as "failed" with the error "JobFoundDead." |
||
| self._mark_related_edi_exchanges_failed() | ||
| return result | ||
|
|
||
| def _mark_related_edi_exchanges_failed(self): | ||
| """Propagate terminal EDI job failures to their exchange records.""" | ||
| supported_methods = { | ||
| "action_exchange_process", | ||
| "action_exchange_receive", | ||
| "action_exchange_send", | ||
| } | ||
|
Comment on lines
+18
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we have I'd suggest to have a constant variable with the functions list, so that it can be relied on here and in the |
||
| jobs = self.filtered( | ||
| lambda job: job.model_name == "edi.exchange.record" | ||
| and job.method_name in supported_methods | ||
| ) | ||
| for job in jobs: | ||
| job.records.sudo()._mark_failed_from_queue_job(job) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there’s an opportunity to create an "on-failure" hook in the queue_job module
https://github.com/OCA/queue/blob/19.0/queue_job/models/queue_job.py#L268
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW when the job is failing, only the job object will be updated through a dedicated function for failure,
and then the modified values are going to be stored on the odoo record: https://github.com/OCA/queue/blob/19.0/queue_job/controllers/main.py#L187-L188
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On fail hooks in queue job: OCA/queue#955