In the base code of ./account_banking_payment_export/model/account_move_line.py
is a functional field delcared
class account_move_line(orm.Model):
_inherit = 'account.move.line'
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)"""
if not ids:
return {}
cr.execute("""SELECT ml.id,
CASE WHEN ml.amount_currency < 0
THEN - ml.amount_currency
ELSE ml.credit
END -
(SELECT coalesce(sum(amount_currency),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""", (tuple(ids),))
r = dict(cr.fetchall())
return r
'amount_to_pay': fields.function(amount_to_pay,type='float', string='Amount to pay', fnct_search=_to_pay_search),
when i use this field in a loop...
for line in move_obj.browse(cr, uid, move_ids, context):
if line.amount_to_pay > 0.00
The moment it read the if line.amount_to_pay > 0.00 it generates a huge query on the postgres DB, i believe for all the account_move_line.
I was expecting just a query for one line, but this is not so...
Has anybody had the same experience with such an issue?