Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] job commit every lines #413

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading