diff --git a/budget_control_advance_clearing/models/hr_expense.py b/budget_control_advance_clearing/models/hr_expense.py index 7b7caee3..098f6404 100644 --- a/budget_control_advance_clearing/models/hr_expense.py +++ b/budget_control_advance_clearing/models/hr_expense.py @@ -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): @@ -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( diff --git a/budget_control_expense/models/account_move_line.py b/budget_control_expense/models/account_move_line.py index 44bc87bc..7073645d 100644 --- a/budget_control_expense/models/account_move_line.py +++ b/budget_control_expense/models/account_move_line.py @@ -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,