From d13ce05c9641c0b56eb4e270339948e59a542874 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Fri, 4 May 2018 16:41:11 +0200 Subject: [PATCH] [FIX] account: use company currency in _compute_matched_percentage in case no currency is set on account.move When a move or move line is supposed to use the company currency, its currency_id field is empty. _compute_matched_percentage did not take this into account, causing the rounding method to sometimes be called with a precision equal to False, resulting in erronous and weird behavior (0 was considered different from 0, causing a division by zero in the following condition). --- addons/account/models/account_move.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 6fe81fbf202..e59d6c78101 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -55,7 +55,8 @@ class AccountMove(models.Model): total_amount += amount for partial_line in (line.matched_debit_ids + line.matched_credit_ids): total_reconciled += partial_line.amount - if float_is_zero(total_amount, precision_rounding=move.currency_id.rounding): + precision_currency = move.currency_id or move.company_id.currency_id + if float_is_zero(total_amount, precision_rounding=precision_currency.rounding): move.matched_percentage = 1.0 else: move.matched_percentage = total_reconciled / total_amount