From 05908a0fac100b1f1083eeb708a6b2b2a76958f1 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 18 Mar 2015 11:29:56 +0100 Subject: [PATCH] [FIX] account_payment: supplier invoice on more then one payment oder The field move_line_id in payment.order.form only shows account move lines that still have an amount to pay. This was lost during 333e83f. --- addons/account_payment/account_move_line.py | 11 +++++++---- addons/account_payment/test/payment_order_process.yml | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index d0ef119640c..9b1a88ad40b 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -27,9 +27,12 @@ class account_move_line(osv.osv): _inherit = "account.move.line" # delegate to parent, used for local fields.function redefinition - def _amount_residual(self, cr, uid, ids, field_names, args, context=None): - return super(account_move_line, self)._amount_residual( - cr, uid, ids, field_names, args, context=context) + def _amount_to_pay(self, cr, uid, ids, field_names, args, context=None): + return { + id: value['amount_residual'] + for id, value in self._amount_residual(cr, uid, ids, field_names, args, + context=context).items() + } def _to_pay_search(self, cr, uid, obj, name, args, context=None): if not args: @@ -95,7 +98,7 @@ class account_move_line(osv.osv): return line2bank _columns = { - 'amount_to_pay': fields.function(_amount_residual, + 'amount_to_pay': fields.function(_amount_to_pay, type='float', string='Amount to pay', fnct_search=_to_pay_search), } diff --git a/addons/account_payment/test/payment_order_process.yml b/addons/account_payment/test/payment_order_process.yml index 5aaf97b9e71..7c93c312c15 100644 --- a/addons/account_payment/test/payment_order_process.yml +++ b/addons/account_payment/test/payment_order_process.yml @@ -60,6 +60,10 @@ assert invoice.partner_id == payment_line.partner_id, "Partner is not correct." assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct." assert invoice.amount_total == payment_line.amount, "Payment amount is not correct." + assert payment_line.move_line_id.amount_to_pay > 0, "Move line paid" + assert len(self.pool("account.move.line").search(cr, uid, + [('amount_to_pay', '>', 0), ('id', '=', payment_line.move_line_id.id)])) == 0, \ + "No payment order found for this move line" - After making all payments, I finish the payment order. -