mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-22 13:42:07 +00:00
6b96b671d6
->account_payment_partner_default_bank
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# Copyright 2014-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
|
# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from flectra import api, fields, models, _
|
|
from flectra.exceptions import ValidationError
|
|
|
|
|
|
class AccountInvoice(models.Model):
|
|
_inherit = 'account.invoice'
|
|
|
|
@api.onchange('partner_id', 'company_id')
|
|
def _onchange_partner_id(self):
|
|
|
|
if self.company_id:
|
|
company = self.company_id
|
|
else:
|
|
company = self.env.user.company_id
|
|
res = super(AccountInvoice, self)._onchange_partner_id()
|
|
if self.type == 'out_invoice' and not self.partner_bank_id:
|
|
bank_id = self._get_partner_bank_id(company.id)
|
|
if bank_id:
|
|
self.partner_bank_id = bank_id
|
|
|
|
return res
|
|
|
|
@api.onchange('payment_mode_id')
|
|
def _onchange_payment_mode_id(self):
|
|
if self.company_id:
|
|
company = self.company_id
|
|
else:
|
|
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:
|
|
bank_id = self._get_partner_bank_id(company.id)
|
|
if bank_id:
|
|
self.partner_bank_id = bank_id
|
|
return res
|