From 69b6cf44bd0294fbd2b7982a9361bb1ef9e805d8 Mon Sep 17 00:00:00 2001 From: Arthur Maniet Date: Tue, 17 Feb 2015 11:07:14 +0100 Subject: [PATCH] [FIX] account: in bank statement reconciliation, show the invoice line from a partial reconciliation. Since all the lines in a partial reconciliation share the same state and the same amount_residual, we need to keep only one 'result' line. It was the first line found that was kept ; now it's the line whose amount is greater than amount_residual, whiwh most likely is the significant one. Fixes #5129 --- addons/account/account_bank_statement.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/account/account_bank_statement.py b/addons/account/account_bank_statement.py index 12188b8860d..ff81ba64421 100644 --- a/addons/account/account_bank_statement.py +++ b/addons/account/account_bank_statement.py @@ -647,7 +647,8 @@ class account_bank_statement_line(osv.osv): mv_line_pool = self.pool.get('account.move.line') domain = self._domain_move_lines_for_reconciliation(cr, uid, st_line, excluded_ids=excluded_ids, str=str, additional_domain=additional_domain, context=context) - # Get move lines ; in case of a partial reconciliation, only consider one line + # Get move lines ; in case of a partial reconciliation, only keep one line (the first whose amount is greater than + # the residual amount because it is presumably the invoice, which is the relevant item in this situation) filtered_lines = [] reconcile_partial_ids = [] actual_offset = offset @@ -656,7 +657,9 @@ class account_bank_statement_line(osv.osv): lines = mv_line_pool.browse(cr, uid, line_ids, context=context) make_one_more_loop = False for line in lines: - if line.reconcile_partial_id and line.reconcile_partial_id.id in reconcile_partial_ids: + if line.reconcile_partial_id and \ + (line.reconcile_partial_id.id in reconcile_partial_ids or \ + abs(line.debit - line.credit) < abs(line.amount_residual)): #if we filtered a line because it is partially reconciled with an already selected line, we must do one more loop #in order to get the right number of items in the pager make_one_more_loop = True