Skip to content

Commit

Permalink
[MIG] sale_automatic_workflow_periodicity: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
henrybackman committed Oct 23, 2024
1 parent a7bfeaf commit d62a247
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
12 changes: 10 additions & 2 deletions sale_automatic_workflow/models/automatic_workflow_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ def _register_payment_invoice(self, invoice):
def _handle_pickings(self, sale_workflow):
pass

def _sale_workflow_domain(self, workflow):
return [("workflow_process_id", "=", workflow.id)]

@api.model
def run_with_workflow(self, sale_workflow):
workflow_domain = [("workflow_process_id", "=", sale_workflow.id)]
workflow_domain = self._sale_workflow_domain(sale_workflow)
if sale_workflow.validate_order:
self.with_context(
send_order_confirmation_mail=sale_workflow.send_order_confirmation_mail
Expand Down Expand Up @@ -206,10 +209,15 @@ def run_with_workflow(self, sale_workflow):
safe_eval(sale_workflow.payment_filter_id.domain) + workflow_domain
)

@api.model
def _workflow_process_to_run_domain(self):
return []

Check warning on line 214 in sale_automatic_workflow/models/automatic_workflow_job.py

View check run for this annotation

Codecov / codecov/patch

sale_automatic_workflow/models/automatic_workflow_job.py#L214

Added line #L214 was not covered by tests

@api.model
def run(self):
"""Must be called from ir.cron"""
sale_workflow_process = self.env["sale.workflow.process"]
for sale_workflow in sale_workflow_process.search([]):
domain = self._workflow_process_to_run_domain()
for sale_workflow in sale_workflow_process.search(domain):
self.run_with_workflow(sale_workflow)
return True
2 changes: 1 addition & 1 deletion sale_automatic_workflow_periodicity/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Sale Automatic Workflow Periodicity",
"summary": "Adds a period for the execution of a workflow.",
"version": "14.0.1.1.0",
"version": "17.0.1.0.0",
"category": "Sales Management",
"license": "AGPL-3",
"author": "Camptocamp, " "Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ class SaleWorkflowProcess(models.Model):
string="Run every (in seconds)",
help="Sets a periodicity for this workflow to be executed (in seconds)",
)
next_execution = fields.Datetime(readonly=True)
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.",
help="When checked only sales created before the last execution "
"will be processed.",
)

def write(self, vals):
Expand Down
1 change: 1 addition & 0 deletions sale_automatic_workflow_periodicity/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- Thierry Ducrest \<<[email protected]>\>
- Simone Orsi \<<[email protected]>\>
- Henry Backman \<<[email protected]>\>
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,38 @@
ref="sale_automatic_workflow.sale_workflow_process_view_form"
/>
<field name="arch" type="xml">

<group name="sale_order_confirm" position="before">
<group
name="workflow_periodicity_exec"
string="Workflow execution periodicity"
>
<field name="periodicity" />
<field name="next_execution" />
<field name="periodicity_check_create_date" />
</group>
</group>

<xpath expr="//div[@name='sale_order_confirm']" position="before">
<div class="container" name="sale_order_confirm">
<h3>
<bold>Workflow execution periodicity</bold>
</h3>
<div class="row">
<div class="col-sm-12">
<label for="periodicity" class="col-lg-4 o_light_label" />
<span>
<field name="periodicity" />
</span>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="next_execution" class="col-lg-4 o_light_label" />
<span>
<field name="next_execution" />
</span>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="periodicity_check_create_date" class="col-lg-4 o_light_label" />
<span>
<field name="periodicity_check_create_date" />
</span>
</div>
</div>
</div>
<br/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit d62a247

Please sign in to comment.