-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] edi_oca: don't consider exchange records if jobs have been created
- Loading branch information
1 parent
4c87527
commit 7c00765
Showing
4 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2024 ForgeFlow S.L. | ||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html) | ||
|
||
import logging | ||
|
||
from odoo import api, models | ||
from odoo.tools import pycompat | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class QueueJob(models.Model): | ||
_inherit = 'queue.job' | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
jobs = super().create(vals_list) | ||
for job, vals in pycompat.izip(jobs, vals_list): | ||
records = job.records.exists() | ||
if len(records) != 1 or records._name != "edi.exchange.record": | ||
continue | ||
if vals.get("state") == "failed" and records.initial_job_id.id == job.id: | ||
records.initial_job_id = False | ||
return jobs | ||
|
||
def write(self, vals): | ||
for job in self: | ||
records = job.records.exists() | ||
if len(records) != 1 or records._name != "edi.exchange.record": | ||
continue | ||
if (vals.get("state") == "failed" and records.initial_job_id.id == job.id | ||
and job.state != "failed"): | ||
records.initial_job_id = False | ||
return super().write(vals) |