mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-23 22:22:05 +00:00
37 lines
1.2 KiB
Python
37 lines
1.2 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:
|
||
|
if company.bank_ids:
|
||
|
self.partner_bank_id = company.bank_ids[0]
|
||
|
|
||
|
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:
|
||
|
if company.bank_ids:
|
||
|
self.partner_bank_id = company.bank_ids[0]
|
||
|
return res
|