Skip to content
Open
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
13 changes: 11 additions & 2 deletions budget_control_advance_clearing/models/hr_expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.tools import float_round


class HRExpenseSheet(models.Model):
Expand Down Expand Up @@ -218,14 +219,22 @@ def uncommit_advance_budget(self):
if self.env.company.budget_include_tax
else clearing.untaxed_amount
)
if clearing.currency_id != clearing.company_id.currency_id:
origin_clearing_amount = clearing.currency_id._convert(
origin_clearing_amount,
clearing.company_id.currency_id,
clearing.company_id,
clearing.date,
)
while origin_clearing_amount > 0:
advance_sheet = clearing.sheet_id.advance_sheet_id
advances = advance_sheet.expense_line_ids.filtered("amount_commit")
if not advances:
break
for advance in advances:
clearing_amount = min(
advance.amount_commit, origin_clearing_amount
clearing_amount = float_round(
min(advance.amount_commit, origin_clearing_amount),
precision_rounding=clearing.company_id.currency_id.rounding,
)
origin_clearing_amount -= clearing_amount
budget_move = advance.commit_budget(
Expand Down
1 change: 1 addition & 0 deletions budget_control_expense/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def uncommit_expense_budget(self):
continue
expense.commit_budget(
reverse=True,
amount_currency=expense.amount_commit,
move_line_id=ml.id,
date=ml.date_commit,
analytic_account_id=expense.fwd_analytic_account_id or False,
Expand Down