From 4769ed4eb79aee7733ed40fe25951b6e868dcea5 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 17 Nov 2016 19:00:24 +0100 Subject: [PATCH] [FIX] base: unique bank account number constraint too restrictive There is a multi-company record rule on `res.partner.bank`, meaning you cannot see the bank accounts of other companies. Making a constraint on `sanitized_acc_number` alone prevent to create a same bank account into different companies, while you cannot see this bank account from the other companies. In this case, the user tries to import its bank statement, and it contains a bank account which already exists in the database but for another company than the one he is currently importing the statement, and, - it cannot find it because of the multi-company rule, - it cannot create it because of the constraint The constraint must take into account the company opw-690969 --- openerp/addons/base/res/res_bank.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openerp/addons/base/res/res_bank.py b/openerp/addons/base/res/res_bank.py index 0acdbe100bb..f262c18d47b 100644 --- a/openerp/addons/base/res/res_bank.py +++ b/openerp/addons/base/res/res_bank.py @@ -67,7 +67,7 @@ class ResPartnerBank(models.Model): company_id = fields.Many2one('res.company', 'Company', default=lambda self: self.env.user.company_id, ondelete='cascade') _sql_constraints = [ - ('unique_number', 'unique(sanitized_acc_number)', 'Account Number must be unique'), + ('unique_number', 'unique(sanitized_acc_number, company_id)', 'Account Number must be unique'), ] @api.one