From 6b96b671d6180bf7a618b9ce57f2791e39a99a77 Mon Sep 17 00:00:00 2001 From: Renzo Meister Date: Thu, 18 Aug 2022 08:12:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20New=20app=20to=20automatically=20se?= =?UTF-8?q?t=20default=20bank=20if=20no=20payment=20mode=20is=20used=20->a?= =?UTF-8?q?ccount=5Fpayment=5Fpartner=5Fdefault=5Fbank?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/account_invoice.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/account_payment_partner_default_bank/models/account_invoice.py b/account_payment_partner_default_bank/models/account_invoice.py index eec45d5..0145038 100644 --- a/account_payment_partner_default_bank/models/account_invoice.py +++ b/account_payment_partner_default_bank/models/account_invoice.py @@ -18,8 +18,9 @@ class AccountInvoice(models.Model): company = self.env.user.company_id res = super(AccountInvoice, self)._onchange_partner_id() if self.type == 'out_invoice' and not self.partner_bank_id: - if company.bank_ids: - self.partner_bank_id = company.bank_ids[0] + bank_id = self._get_partner_bank_id(company.id) + if bank_id: + self.partner_bank_id = bank_id return res @@ -31,6 +32,7 @@ class AccountInvoice(models.Model): company = self.env.user.company_id res = super(AccountInvoice, self)._onchange_payment_mode_id() if self.type == 'out_invoice' and not self.partner_bank_id: - if company.bank_ids: - self.partner_bank_id = company.bank_ids[0] + bank_id = self._get_partner_bank_id(company.id) + if bank_id: + self.partner_bank_id = bank_id return res