From cbb0f41426133cf5da6aab826b915aa0bc08cfc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 29 Sep 2014 22:06:15 +0200 Subject: [PATCH] [IMP] do not attempt to create transfer moves for payment lines without associated ar/ap move line Otherwise, it is not possible to execute such payment order if the payment mode has a transfer account. And I can't see how it could make sense if the transfer move cannot be reconciled in the first place. --- .../model/account_payment.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/account_banking_payment_transfer/model/account_payment.py b/account_banking_payment_transfer/model/account_payment.py index 4a56cfa1b..b027f99d6 100644 --- a/account_banking_payment_transfer/model/account_payment.py +++ b/account_banking_payment_transfer/model/account_payment.py @@ -207,12 +207,7 @@ class payment_order(orm.Model): self, cr, uid, order, line, vals, context=None): vals.update({ 'partner_id': line.partner_id.id, - 'account_id': (line.move_line_id - and line.move_line_id.account_id.id - or False), - # if not line.move_line_id, the field 'account_id' must be set by - # another module that inherit this function, like for example in - # the module purchase_payment_order + 'account_id': line.move_line_id.account_id.id, 'credit': (order.payment_order_type == 'debit' and line.amount or 0.0), 'debit': (order.payment_order_type == 'payment' @@ -242,8 +237,10 @@ class payment_order(orm.Model): or not order.mode.transfer_account_id: continue for line in order.line_ids: + if not line.move_line_id: + continue # basic checks - if line.move_line_id and line.move_line_id.reconcile_id: + if line.move_line_id.reconcile_id: raise orm.except_orm( _('Error'), _('Move line %s has already been paid/reconciled')