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