From d8e33d1fc5cc88da36180020dc028d8017cbe35c Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Mon, 4 Jan 2010 14:47:23 +0530 Subject: [PATCH] [FIX] Residual amount was calculated wrongly when invoice had payment term lines lp bug: https://launchpad.net/bugs/371681 fixed bzr revid: jvo@tinyerp.com-20100104091723-o6fkke202w22egoy --- addons/account/invoice.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 77a96b3140e..c5d9b5b2eb7 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -150,7 +150,9 @@ class account_invoice(osv.osv): if not move_lines: res[id] = [] continue + res[id] = [] data_lines = self.pool.get('account.move.line').browse(cr,uid,move_lines) + partial_ids = []# Keeps the track of ids where partial payments are done with payment terms for line in data_lines: ids_line = [] if line.reconcile_id: @@ -158,7 +160,8 @@ class account_invoice(osv.osv): elif line.reconcile_partial_id: ids_line = line.reconcile_partial_id.line_partial_ids l = map(lambda x: x.id, ids_line) - res[id]=[x for x in l if x <> line.id] + partial_ids.append(line.id) + res[id] =[x for x in l if x <> line.id and x not in partial_ids] return res def _get_invoice_line(self, cr, uid, ids, context=None): @@ -180,11 +183,14 @@ class account_invoice(osv.osv): src = [] lines = [] for m in self.pool.get('account.move.line').browse(cr, uid, moves, context): + temp_lines = []#Added temp list to avoid duplicate records if m.reconcile_id: - lines += map(lambda x: x.id, m.reconcile_id.line_id) + temp_lines = map(lambda x: x.id, m.reconcile_id.line_id) elif m.reconcile_partial_id: - lines += map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) + temp_lines = map(lambda x: x.id, m.reconcile_partial_id.line_partial_ids) + lines += [x for x in temp_lines if x not in lines] src.append(m.id) + lines = filter(lambda x: x not in src, lines) result[invoice.id] = lines return result