mirror of
https://gitlab.com/flectra-community/l10n-switzerland-flectra.git
synced 2024-12-24 13:21:46 +00:00
25 lines
1.1 KiB
Python
25 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
|
|
|
|
from flectra import models, fields, api, _
|
|
from flectra.addons.l10n_ch.models.res_bank import _is_l10n_ch_postal
|
|
|
|
class AccountBankStatementLine(models.Model):
|
|
|
|
_inherit = "account.bank.statement.line"
|
|
|
|
def _find_or_create_bank_account(self):
|
|
if self.company_id.country_id.code == 'CH' and _is_l10n_ch_postal(self.account_number):
|
|
bank_account = self.env['res.partner.bank'].search(
|
|
[('company_id', '=', self.company_id.id),
|
|
('sanitized_acc_number', 'like', self.account_number + '%'),
|
|
('partner_id', '=', self.partner_id.id)])
|
|
if not bank_account:
|
|
bank_account = self.env['res.partner.bank'].create({
|
|
'company_id': self.company_id.id,
|
|
'acc_number': self.account_number + " " + self.partner_id.name,
|
|
'partner_id': self.partner_id.id
|
|
})
|
|
return bank_account
|
|
else:
|
|
super(AccountBankStatementLine, self)._find_or_create_bank_account() |