From fc276359fca2fbba7ab3c96ba6d656f0df7f1921 Mon Sep 17 00:00:00 2001 From: "Touati Djamel (otd)" Date: Fri, 11 Feb 2022 09:58:18 +0000 Subject: [PATCH] [FIX] base: allow removing the contact barcode Steps to reproduce the bug: - Go to any Contact > Sales and Purchase tab - Edit > Change the barcode, and click Save - Then click Edit, and try to erase (empty) the barcode > save Problem: A validation error is triggered, the constraint will check if other partners do not have the same barcode but as it is empty there will be several other partners Solution: When the barcode is empty, no need to check if other partners have the same opw-2753291 closes odoo/odoo#84450 X-original-commit: 32754ebc6f5f1b3c739d0a39ef209822fa4ed3a1 Signed-off-by: William Henrotin (whe) Signed-off-by: Djamel Touati (otd) --- odoo/addons/base/models/res_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index 3e95f19102a..b7064decefb 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -440,7 +440,7 @@ class Partner(models.Model): @api.constrains('barcode') def _check_barcode_unicity(self): - if self.env['res.partner'].search_count([('barcode', '=', self.barcode)]) > 1: + if self.barcode and self.env['res.partner'].search_count([('barcode', '=', self.barcode)]) > 1: raise ValidationError('An other user already has this barcode') def _update_fields_values(self, fields):