[MIG] contract_queue_job: Migration to 14.0

This commit is contained in:
Yannis Burkhalter
2022-11-16 14:29:55 +01:00
committed by Luis Rodriguez
parent bcf0e01f49
commit 7191ec6db3
12 changed files with 142 additions and 50 deletions

View File

@@ -1,23 +1,28 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import ast
from odoo import api, models
from odoo.addons.queue_job.job import job
QUEUE_CHANNEL = "root.CONTRACT_INVOICE"
from odoo import models
class ContractContract(models.Model):
_inherit = "contract.contract"
@api.multi
@job(default_channel=QUEUE_CHANNEL)
def _recurring_create_invoice(self, date_ref=False):
res = self.env["account.invoice"]
if len(self) > 1:
as_job = (
self.env["ir.config_parameter"]
.sudo()
.get_param("contract.queue.job", default=False)
)
try:
as_job = ast.literal_eval(as_job) if as_job else False
except ValueError:
as_job = False
if as_job and len(self) > 1:
for rec in self:
rec.with_delay()._recurring_create_invoice(date_ref=date_ref)
return res
return self.env["account.move"]
return super()._recurring_create_invoice(date_ref=date_ref)