[FIX] account_payment: compute amount to pay

compute the amount_to_pay with  function field amount_residual on
account.move.line

opw:628903, 628428
This commit is contained in:
Goffin Simon 2015-03-13 10:35:48 +01:00
parent 2275af4b77
commit 4530faae8b
1 changed files with 7 additions and 9 deletions

View File

@ -29,16 +29,14 @@ class account_move_line(osv.osv):
def amount_to_pay(self, cr, uid, ids, name, arg=None, context=None):
""" Return the amount still to pay regarding all the payemnt orders
(excepting cancelled orders)"""
res = {}
if not ids:
return {}
res = dict.fromkeys(ids, 0.0)
cr.execute("""SELECT ml.id,
(SELECT sum(coalesce(residual, 0))
FROM account_invoice
WHERE move_id = ml.move_id)
FROM account_move_line ml
WHERE id IN %s""", (tuple(ids),))
res.update(cr.fetchall())
return res
for ml in self.browse(cr, uid, ids, context=context):
if ml.amount_currency:
res[ml.id] = ml.amount_residual_currency
else:
res[ml.id] = ml.amount_residual
return res
def _to_pay_search(self, cr, uid, obj, name, args, context=None):