| 1 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 2 |
from odoo import _, api, fields, models |
| 3 |
from odoo.exceptions import ValidationError |
| 4 |
|
| 5 |
|
| 6 |
class ResBank(models.Model): |
| 7 |
_inherit = "res.bank" |
| 8 |
|
| 9 |
intermediary_bank_id = fields.Many2one( |
| 10 |
comodel_name='res.bank', |
| 11 |
domain="[('id', '!=', id)]", |
| 12 |
help="An intermediary bank facilitates international wire transfers between your bank and the beneficiary's bank when they don’t have a direct relationship.", |
| 13 |
) |
| 14 |
|
| 15 |
@api.constrains("intermediary_bank_id") |
| 16 |
def _constrains_intermediary_bank_id(self): |
| 17 |
for bank in self: |
| 18 |
if bank == bank.intermediary_bank_id: |
| 19 |
raise ValidationError(_("A bank cannot be its own intermediary bank.")) |