Skip to content

Commit

Permalink
[FIX] support uncommit budget contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Oct 17, 2023
1 parent 836d751 commit b16b445
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
3 changes: 2 additions & 1 deletion budget_allocation/models/base_budget_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def _get_query_dict(self, docline):
)
)
)
return self.env.cr.dictfetchall()
dict_data = self.env.cr.dictfetchall()
return dict_data

@api.model
def check_budget_allocation_limit(self, doclines):
Expand Down
1 change: 0 additions & 1 deletion budget_control_contract/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import base_budget_move
from . import account_budget_move
from . import contract_budget_move
from . import budget_period
Expand Down
23 changes: 23 additions & 0 deletions budget_control_contract/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AccountMoveLine(models.Model):

def uncommit_contract_budget(self):
"""For vendor bill in valid state, do uncommit for related contract."""
ForwardLine = self.env["budget.commit.forward.line"]
for ml in self:
inv_state = ml.move_id.state
move_type = ml.move_id.move_type
Expand All @@ -31,9 +32,31 @@ def uncommit_contract_budget(self):
contract_line = contract_line.with_context(
return_amount_commit=ml.amount_commit
)
# Check case forward commit,
# it should uncommit with forward commit or old analytic
analytic_account = False
if contract_line.fwd_analytic_account_id:
# Case actual use analytic same as CT Commit,
# it will uncommit with CT analytic
if contract_line.analytic_account_id == ml.analytic_account_id:
analytic_account = contract_line.analytic_account_id
else:
# Case actual commit is use analytic not same as PO Commit
domain_fwd_line = self._get_domain_fwd_line(contract_line)
fwd_lines = ForwardLine.search(domain_fwd_line)
for fwd_line in fwd_lines:
if (
fwd_line.forward_id.to_budget_period_id.bm_date_from
<= ml.date_commit
<= fwd_line.forward_id.to_budget_period_id.bm_date_to
):
analytic_account = fwd_line.to_analytic_account_id
break
# Confirm vendor bill, do uncommit budget
contract_line.commit_budget(
reverse=rev,
move_line_id=ml.id,
analytic_account_id=analytic_account,
quantity=qty,
date=ml.date_commit,
)
Expand Down
23 changes: 0 additions & 23 deletions budget_control_contract/models/base_budget_move.py

This file was deleted.

0 comments on commit b16b445

Please sign in to comment.