blob: 2bfae1aed745e9458cfd42b9dd190b46ae920e7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# -*- coding: utf-8 -*-
from odoo.exceptions import ValidationError
from odoo import api, fields, models, _
class ResPartnerBank(models.Model):
_inherit = "res.partner.bank"
journal_id = fields.One2many('account.journal', 'bank_account_id', domain=[('type', '=', 'bank')], string='Account Journal', readonly=True,
help="The accounting journal corresponding to this bank account.")
@api.constrains('journal_id')
def _check_journal_id(self):
for bank in self:
if len(bank.journal_id) > 1:
raise ValidationError(_('A bank account can belong to only one journal.'))
|