[FIX] account: computation of debit/credit on partner is based on past year moves instead of reported entries, courtesy of Nhomar Hernandez (vauxoo)

This change allows to have consistency in values instead of depending on when the fiscal year is closed and when the entries are generated

lp bug: https://launchpad.net/bugs/1219381 fixed

bzr revid: mat@openerp.com-20131022095301-tigk2ixheljvqxwc
This commit is contained in:
Martin Trigaux 2013-10-22 11:53:01 +02:00
commit 26256ee55a
1 changed files with 4 additions and 3 deletions

View File

@ -110,14 +110,15 @@ class res_partner(osv.osv):
_description = 'Partner'
def _credit_debit_get(self, cr, uid, ids, field_names, arg, context=None):
query = self.pool.get('account.move.line')._query_get(cr, uid, context=context)
ctx = context.copy()
ctx['all_fiscalyear'] = True
query = self.pool.get('account.move.line')._query_get(cr, uid, context=ctx)
cr.execute("""SELECT l.partner_id, a.type, SUM(l.debit-l.credit)
FROM account_move_line l
LEFT JOIN account_account a ON (l.account_id=a.id)
WHERE a.type IN ('receivable','payable')
AND l.partner_id IN %s
AND (l.reconcile_id IS NULL OR
reconcile_id in (SELECT id FROM account_move_reconcile WHERE opening_reconciliation is TRUE))
AND l.reconcile_id IS NULL
AND """ + query + """
GROUP BY l.partner_id, a.type
""",