From 26e769eb8836d8d1b7fe915a0a104fc26354bad3 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 18 Mar 2013 12:30:43 +0100 Subject: [PATCH] [FIX] Change SQL query for manual reconciliation partners such that partners appear when needed bzr revid: jco@openerp.com-20130318113043-fm2gc0yrln630vjf --- addons/account/account_move_line.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index a96ed889aae..4aa7da9428e 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -741,20 +741,17 @@ class account_move_line(osv.osv): def list_partners_to_reconcile(self, cr, uid, context=None): cr.execute( - """ - SELECT partner_id - FROM ( - SELECT l.partner_id, p.last_reconciliation_date, SUM(l.debit) AS debit, SUM(l.credit) AS credit + """SELECT partner_id FROM ( + SELECT l.partner_id, p.last_reconciliation_date, SUM(l.debit) AS debit, SUM(l.credit) AS credit, MAX(l.date) AS max_reconcil_date FROM account_move_line l RIGHT JOIN account_account a ON (a.id = l.account_id) RIGHT JOIN res_partner p ON (l.partner_id = p.id) WHERE a.reconcile IS TRUE AND l.reconcile_id IS NULL - AND (p.last_reconciliation_date IS NULL OR l.date > p.last_reconciliation_date) AND l.state <> 'draft' GROUP BY l.partner_id, p.last_reconciliation_date ) AS s - WHERE debit > 0 AND credit > 0 + WHERE debit > 0 AND credit > 0 AND (last_reconciliation_date IS NULL OR max_reconcil_date > last_reconciliation_date) ORDER BY last_reconciliation_date""") ids = cr.fetchall() ids = len(ids) and [x[0] for x in ids] or []