[FIX] Change SQL query for manual reconciliation partners such that partners appear when needed
bzr revid: jco@openerp.com-20130318113043-fm2gc0yrln630vjf
This commit is contained in:
parent
9485c49f4f
commit
26e769eb88
|
@ -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 []
|
||||
|
|
Loading…
Reference in New Issue