From 1a7792f938fb3ffe780a341a2041b2cda1f18ea8 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Fri, 13 Dec 2024 10:14:54 +0700 Subject: [PATCH 1/2] [FIX] budget_control_advance and expense: support multi currency --- budget_control_advance_clearing/models/hr_expense.py | 7 +++++++ budget_control_expense/models/account_move_line.py | 1 + 2 files changed, 8 insertions(+) diff --git a/budget_control_advance_clearing/models/hr_expense.py b/budget_control_advance_clearing/models/hr_expense.py index 7b7caee3..285cc9f9 100644 --- a/budget_control_advance_clearing/models/hr_expense.py +++ b/budget_control_advance_clearing/models/hr_expense.py @@ -218,6 +218,13 @@ 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") 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, From 1a25e674982468ed8b25db1de9fa3d8394e8a6a3 Mon Sep 17 00:00:00 2001 From: Saran440 Date: Wed, 5 Feb 2025 11:04:23 +0700 Subject: [PATCH 2/2] [FIX] rounding amount_commit before compare --- budget_control_advance_clearing/models/hr_expense.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/budget_control_advance_clearing/models/hr_expense.py b/budget_control_advance_clearing/models/hr_expense.py index 285cc9f9..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): @@ -231,8 +232,9 @@ def uncommit_advance_budget(self): 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(