[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) <whe@odoo.com> Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user