Skip to content
Browse files

[FIX] account: missing partner bank account in vendor credit note

Have a partner (vendor) with a bank account.
Create a Vendor Bills. Change the form view of the vendors bills to
display the field partner_bank_id ('Bank account').
The field shows correctly the bank account of the vendor.

Before this commit, when creating a Credit Note, the field
partner_bank_id is empty.

Now, the field parnet_bank_id is the one of the Company.

  • Loading branch information...
jpp-odoo committed Mar 4, 2019
1 parent 443b810 commit 9bbaf0e72b1838e3d85bc2cefd3a4354ea745eb0
Showing with 45 additions and 6 deletions.
  1. +14 −6 addons/account/models/
  2. +31 −0 addons/account/tests/
@@ -499,16 +499,19 @@ def default_get(self,default_fields):
res = super(AccountInvoice, self).default_get(default_fields)

if not res.get('type', False) == 'out_invoice' or not 'company_id' in res:
if res.get('type', False) not in ('out_invoice', 'in_refund') or not 'company_id' in res:
return res

company = self.env[''].browse(res['company_id'])
if company.partner_id:
partner_bank_result = self.env[''].search([('partner_id', '=',], limit=1)
if partner_bank_result:
res['partner_bank_id'] =
partner_bank_result = self._get_partner_bank_id(res['company_id'])
if partner_bank_result:
res['partner_bank_id'] =
return res

def _get_partner_bank_id(self, company_id):
company = self.env[''].browse(company_id)
if company.partner_id:
return self.env[''].search([('partner_id', '=',], limit=1)

def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
def get_view_id(xid, name):
@@ -1353,6 +1356,11 @@ def _prepare_refund(self, invoice, date_invoice=None, date=None, description=Non
values['payment_term_id'] = False
values['refund_invoice_id'] =

if values['type'] == 'in_refund':
partner_bank_result = self._get_partner_bank_id(values['company_id'])
if partner_bank_result:
values['partner_bank_id'] =

if date:
values['date'] = date
if description:
@@ -105,3 +105,34 @@ def test_supplier_invoice2(self):
#I cancel the account move which is in posted state and verifies that it gives warning message
with self.assertRaises(Warning):

def test_vendor_bill_refund(self):
invoice_account = self.env['account.account'].search(
[('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1)
invoice_line_account = self.env['account.account'].search(
[('user_type_id', '=', self.env.ref('account.data_account_type_expenses').id)], limit=1)
bank = self.env[''].create({
'acc_number': '12345678910',
'partner_id': self.env.ref('base.main_partner').id,

invoice_id = self.env['account.invoice'].create({
'name': 'invoice test refund',
'reference_type': 'none',
'partner_id': self.env.ref("base.res_partner_2").id,
'currency_id': self.env.ref('base.USD').id,
'type': 'in_invoice',
'product_id': self.env.ref("product.product_product_4").id,
'quantity': 1,
'price_unit': 15.0,
'name': 'something',

refund_invoices = invoice_id.refund()

self.assertEqual(refund_invoices.partner_bank_id, bank)

0 comments on commit 9bbaf0e

Please sign in to comment.
You can’t perform that action at this time.