Skip to content

Commit

Permalink
Merge pull request #413 from ecosoft-odoo/14.0-add-budget_control_job
Browse files Browse the repository at this point in the history
[FIX] job commit every lines
  • Loading branch information
Saran440 authored Sep 28, 2023
2 parents 9e767ab + b56d6f8 commit 59626e9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
26 changes: 26 additions & 0 deletions budget_control_job/models/budget_commit_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,36 @@ class BudgetCommitForward(models.Model):
string="Job UUID",
readonly=True,
)
is_done = fields.Boolean(readonly=True)

def action_budget_commit_forward_job(self):
description = _("Creating forward commit budget with id %s") % (self.id,)
job = self.with_delay(description=description).action_budget_commit_forward()
# Update UUID in forward commit
self.job_uuid = job.uuid
return "Job created with uuid {}".format(job.uuid)

def action_budget_commit_forward(self):
"""Overwrite function recompute"""
self._do_forward_commit()
self.write({"state": "done"})
self._do_update_initial_commit()
# Recompute budget on document number
documents = []
for line in self.forward_line_ids:
if line.is_done:
continue
doc = line.document_number
if doc not in documents:
doc.recompute_budget_move()
documents.append(doc)
line.is_done = True
self.env.cr.commit()
if all(line.is_done for line in self.forward_line_ids):
self.is_done = True


class BudgetCommitForwardLine(models.Model):
_inherit = "budget.commit.forward.line"

is_done = fields.Boolean(readonly=True)
15 changes: 15 additions & 0 deletions budget_control_job/views/budget_commit_forward_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<field name="arch" type="xml">
<xpath expr="//group/group[2]" position="inside">
<field name="job_uuid" />
<field name="is_done" />
</xpath>
<xpath
expr="//button[@name='preview_budget_commit_forward_info']"
Expand All @@ -19,4 +20,18 @@
</xpath>
</field>
</record>

<record id="view_budget_commit_forward_line_tree" model="ir.ui.view">
<field name="name">view.budget.commit.forward.line.tree</field>
<field name="model">budget.commit.forward.line</field>
<field
name="inherit_id"
ref="budget_control.view_budget_commit_forward_line_tree"
/>
<field name="arch" type="xml">
<xpath expr="//tree" position="inside">
<field name="is_done" optional="hide" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 59626e9

Please sign in to comment.