From 07f26de30fa4a70582750be097d42986b18f9fea Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 23 Jun 2014 11:45:26 +0200 Subject: [PATCH] Suggested by Stefan Rijnhart : check for the payment_mode_id before asking its bank_id.id --- account_payment_partner/model/account_invoice.py | 1 + account_payment_sale/model/sale.py | 3 ++- account_payment_sale_stock/model/stock.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/account_payment_partner/model/account_invoice.py b/account_payment_partner/model/account_invoice.py index 9e02ea476..607cda29a 100644 --- a/account_payment_partner/model/account_invoice.py +++ b/account_payment_partner/model/account_invoice.py @@ -48,6 +48,7 @@ class account_invoice(orm.Model): 'payment_mode_id': partner.customer_payment_mode.id or False, 'partner_bank_id': + partner.customer_payment_mode and partner.customer_payment_mode.bank_id.id or False, }) else: diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py index 1c82e9d35..5951f96af 100644 --- a/account_payment_sale/model/sale.py +++ b/account_payment_sale/model/sale.py @@ -49,6 +49,7 @@ class sale_order(orm.Model): cr, uid, order, lines, context=context) invoice_vals.update({ 'payment_mode_id': order.payment_mode_id.id or False, - 'partner_bank_id': order.payment_mode_id.bank_id.id or False, + 'partner_bank_id': order.payment_mode_id and + order.payment_mode_id.bank_id.id or False, }) return invoice_vals diff --git a/account_payment_sale_stock/model/stock.py b/account_payment_sale_stock/model/stock.py index 85286c9a1..5ed4fbd4f 100644 --- a/account_payment_sale_stock/model/stock.py +++ b/account_payment_sale_stock/model/stock.py @@ -35,6 +35,7 @@ class stock_picking(orm.Model): if picking.sale_id: invoice_vals.update({ 'partner_bank_id': + picking.sale_id.payment_mode_id and picking.sale_id.payment_mode_id.bank_id.id or False, 'payment_mode_id': picking.sale_id.payment_mode_id.id or False,