Fix field function to always return value for all ids
bzr revid: ced-8a474d00eef4a053243156238f433a8aaefd569d
This commit is contained in:
parent
eb2d8e08b9
commit
6c70c60e37
|
@ -32,10 +32,20 @@ class account_move_line(osv.osv):
|
|||
_inherit = "account.move.line"
|
||||
|
||||
def amount_to_pay(self, cr, uid, ids, name, arg={}, context={}):
|
||||
""" Return the amount still to pay regarding all the payemnt orders (excepting cancelled orders)"""
|
||||
""" Return the amount still to pay regarding all the payemnt orders
|
||||
(excepting cancelled orders)"""
|
||||
if not ids:
|
||||
return {}
|
||||
cr.execute("SELECT ml.id,ml.credit - (select coalesce(sum(amount),0) from payment_line pl inner join payment_order po on (pl.order_id = po.id)where move_line_id = ml.id and po.state != 'cancel') as amount from account_move_line ml where credit > 0 and id in (%s)"% (",".join(map(str,ids))))
|
||||
cr.execute("""SELECT ml.id,
|
||||
ml.credit -
|
||||
(SELECT coalesce(sum(amount),0)
|
||||
FROM payment_line pl
|
||||
INNER JOIN payment_order po
|
||||
ON (pl.order_id = po.id)
|
||||
WHERE move_line_id = ml.id
|
||||
AND po.state != 'cancel') as amount
|
||||
FROM account_move_line ml
|
||||
WHERE id in (%s)""" % (",".join(map(str, ids))))
|
||||
r=dict(cr.fetchall())
|
||||
return r
|
||||
|
||||
|
|
|
@ -80,17 +80,21 @@ class payment_order(osv.osv):
|
|||
|
||||
def _total(self, cr, uid, ids, name, args, context={}):
|
||||
if not ids: return {}
|
||||
cr.execute("""select o.id, coalesce(sum(amount),0)
|
||||
from payment_order o left join payment_line l on (o.id = l.order_id)
|
||||
where o.id in (%s) group by o.id"""% ','.join(map(str,ids)))
|
||||
cr.execute("""SELECT o.id, coalesce(sum(l.amount),0)
|
||||
FROM payment_order o
|
||||
LEFT JOIN payment_line l
|
||||
ON (o.id = l.order_id)
|
||||
WHERE o.id in (%s)
|
||||
GROUP BY o.id""" % ','.join(map(str,ids)))
|
||||
return dict(cr.fetchall())
|
||||
|
||||
def nb_line(self, cr, uid, ids, name, args, context={}):
|
||||
if not ids: return {}
|
||||
res= {}.fromkeys(ids,0)
|
||||
cr.execute("""select "order_id",count(*)
|
||||
from payment_line
|
||||
where "order_id" in (%s) group by "order_id" """% ','.join(map(str,ids)))
|
||||
cr.execute("""SELECT "order_id", count(*)
|
||||
FROM payment_line
|
||||
WHERE "order_id" in (%s)
|
||||
GROUP BY "order_id" """ % ','.join(map(str,ids)))
|
||||
res.update(dict(cr.fetchall()))
|
||||
return res
|
||||
|
||||
|
@ -188,12 +192,13 @@ class payment_line(osv.osv):
|
|||
return {}
|
||||
line=self.pool.get('account.move.line').browse(cr,uid,move_line_id)
|
||||
return {'value': {'amount': line.amount_to_pay,
|
||||
'to_pay': line.amount_to_pay,
|
||||
'partner_id': line.partner_id.id,
|
||||
'reference': line.ref,
|
||||
'date_created': line.date_created,
|
||||
'bank_id': self.pool.get('account.move.line').line2bank(cr,uid,[move_line_id],
|
||||
payment_type or 'manual',context)[move_line_id]
|
||||
}}
|
||||
'to_pay': line.amount_to_pay,
|
||||
'partner_id': line.partner_id.id,
|
||||
'reference': line.ref,
|
||||
'date_created': line.date_created,
|
||||
'bank_id': self.pool.get('account.move.line').line2bank(cr, uid,
|
||||
[move_line_id],
|
||||
payment_type or 'manual',context)[move_line_id]
|
||||
}}
|
||||
|
||||
payment_line()
|
||||
|
|
Loading…
Reference in New Issue