Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
from . import automatic_workflow_job
from . import sale_workflow_process

View File

@@ -0,0 +1,42 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import api, fields, models
class AutomaticWorkflowJob(models.Model):
_inherit = "automatic.workflow.job"
def run_with_workflow(self, sale_workflow):
res = super().run_with_workflow(sale_workflow)
if sale_workflow.periodicity:
sale_workflow.next_execution = fields.Datetime.add(
fields.Datetime.now(), seconds=sale_workflow.periodicity
)
return res
@api.model
def _workflow_process_to_run_domain(self):
return [
"|",
("periodicity", "=", 0),
"|",
"&",
("periodicity", ">", 0),
("next_execution", "<=", fields.Datetime.now()),
("next_execution", "=", False),
]
def _sale_workflow_domain(self, workflow):
domain = super()._sale_workflow_domain(workflow)
if workflow.periodicity_check_create_date:
domain.append(
(
"create_date",
"<",
fields.Datetime.subtract(
fields.Datetime.now(), seconds=workflow.periodicity
),
)
)
return domain

View File

@@ -0,0 +1,29 @@
# Copyright 2023 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
from odoo import fields, models
class SaleWorkflowProcess(models.Model):
_inherit = "sale.workflow.process"
periodicity = fields.Integer(
string="Run every (in seconds)",
help="Sets a periodicity for this workflow to be executed (in seconds)",
)
next_execution = fields.Datetime()
periodicity_check_create_date = fields.Boolean(
string="Enforce on creation time",
help="When checked only sales created before the last execution "
"will be processed.",
)
def write(self, vals):
if "periodicity" in vals.keys():
periodicity = vals["periodicity"]
if periodicity == 0:
vals["next_execution"] = False
else:
now = fields.Datetime.now()
vals["next_execution"] = fields.Datetime.add(now, seconds=periodicity)
return super().write(vals)