Search code examples
odoo

Odoo: Is it possible to use the same Bank Account for multiple Contacts?


I was importing my creditor list from another system into Odoo 12 Community version and found out, that it is not possible to use the same account number for a Contact:

duplicate key value violates unique constraint "res_partner_bank_unique_number"

That means, that field acc_number on res.partner.bank model must be unique?

I have some creditors, that share Bank Accounts. How to enable possibility to choose multiple Contacts for one Bank Account? Is that even possible? Is there any module for it?


Solution

  • The possible solution would be to change sql_constraints for res.partner.bank model as it was done here: https://github.com/wtaferner/odoo/commit/326727bbd7161f6c2af68009d3d9fc924772d665 to

    _sql_constraints = [
            ('unique_number', 'unique(sanitized_acc_number, company_id, partner_id)', 'Account Number must be unique for Partner'),
        ]