Skip to content

Commit

Permalink
Merge branch '16.0' of https://github.com/ecosoft-odoo/budgeting into…
Browse files Browse the repository at this point in the history
… 16.0-mig-budget_activity
  • Loading branch information
Saran440 committed Sep 24, 2024
2 parents 2236264 + 107211e commit cb13adf
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 275 deletions.
1 change: 1 addition & 0 deletions budget_control/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"web_widget_x2many_2d_matrix",
],
"data": [
"data/budget_data.xml",
"data/sequence_data.xml",
"security/budget_control_security_groups.xml",
"security/budget_control_rules.xml",
Expand Down
7 changes: 7 additions & 0 deletions budget_control/data/budget_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="decimal_budget_precision" model="decimal.precision" forcecreate="True">
<field name="name">Budget Precision</field>
<field name="digits">2</field>
</record>
</odoo>
3 changes: 3 additions & 0 deletions budget_control/models/base_budget_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ class BaseBudgetMove(models.AbstractModel):
)
amount_currency = fields.Float(
required=True,
digits="Budget Precision",
help="Amount in multi currency",
)
credit = fields.Float(
readonly=True,
digits="Budget Precision",
)
debit = fields.Float(
readonly=True,
digits="Budget Precision",
)
company_id = fields.Many2one(
comodel_name="res.company",
Expand Down
31 changes: 20 additions & 11 deletions budget_control/models/budget_commit_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,16 @@ def _do_forward_commit(self, reverse=False):
# For case extend
for line in rec.forward_line_ids:
if not reverse and line.method_type == "extend":
line.to_analytic_account_id.bm_date_to = (
rec.to_budget_period_id.bm_date_to
)
# Update end date of analytic account,
# if it is extended by max date.
if line.to_analytic_account_id.bm_date_to:
date_to = max(
line.to_analytic_account_id.bm_date_to,
rec.to_budget_period_id.bm_date_to,
)
else:
date_to = rec.to_budget_period_id.bm_date_to
line.to_analytic_account_id.bm_date_to = date_to

def _do_update_initial_commit(self, reverse=False):
"""Update all Analytic Account's initial commit value related to budget period"""
Expand Down Expand Up @@ -298,15 +305,17 @@ def action_budget_commit_forward(self):
self._recompute_budget_move()

def action_cancel(self):
"""Do not allow cancel document is past period."""
forwards = self.env["budget.commit.forward"].search([("state", "=", "done")])
max_date_commit = max(forwards.mapped("to_date_commit"))
# Not allow cancel document is past period.
if max_date_commit and any(
rec.to_date_commit < max_date_commit for rec in self
):
raise UserError(
_("Unable to cancel this document as it belongs to a past period.")
)
if forwards:
max_date_commit = max(forwards.mapped("to_date_commit"))
# Not allow cancel document is past period.
if max_date_commit and any(
rec.to_date_commit < max_date_commit for rec in self
):
raise UserError(
_("Unable to cancel this document as it belongs to a past period.")
)
self.filtered(lambda l: l.state == "done")._do_forward_commit(reverse=True)
self.write({"state": "cancel"})
self._do_update_initial_commit(reverse=True)
Expand Down
1 change: 1 addition & 0 deletions budget_control/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def setUpClass(cls):
cls.Partner = cls.env["res.partner"]
cls.Move = cls.env["account.move"]
cls.BudgetAdjust = cls.env["budget.move.adjustment"]
cls.CommitForward = cls.env["budget.commit.forward"]

# Create vendor
cls.vendor = cls.Partner.create({"name": "Sample Vendor"})
Expand Down
Loading

0 comments on commit cb13adf

Please sign in to comment.