From 174d3fdd668b5f2aa5308608a024ad243c348927 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 3 Feb 2017 10:24:01 +0100 Subject: [PATCH] [FIX] account: bank account on invoice In case of a supplier invoice or a customer refund, it is not possible to set a bank account if the partner is not the commercial partner. opw-705528 --- addons/account/account_invoice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 2e48a12f70d..cf0d6a399fa 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -432,8 +432,8 @@ class account_invoice(models.Model): fiscal_position = False bank_id = False + p = self.env['res.partner'].browse(partner_id or False) if partner_id: - p = self.env['res.partner'].browse(partner_id) rec_account = p.property_account_receivable pay_account = p.property_account_payable if company_id: @@ -461,7 +461,6 @@ class account_invoice(models.Model): account_id = pay_account.id payment_term_id = p.property_supplier_payment_term.id fiscal_position = p.property_account_position.id - bank_id = p.bank_ids and p.bank_ids[0].id or False result = {'value': { 'account_id': account_id, @@ -469,8 +468,11 @@ class account_invoice(models.Model): 'fiscal_position': fiscal_position, }} - if type in ('in_invoice', 'in_refund'): + if type in ('in_invoice', 'out_refund'): + bank_ids = p.commercial_partner_id.bank_ids + bank_id = bank_ids[0].id if bank_ids else False result['value']['partner_bank_id'] = bank_id + result['domain'] = {'partner_bank_id': [('id', 'in', bank_ids.ids)]} if payment_term != payment_term_id: if payment_term_id: