Working on V6.1 on window.
I have added this constraint on a custom module to force the default_code (Product Reference) to be unique but it does not work i can still add products with similar references.
'default_code': fields.char('Reference', size=80, select=True, required=True),
}
_sql_constraints = [
('code_uniq', 'unique(default_code)', ("There is a similar SKU/References already in the system please specify another name, SKU must be UNIQUE!"))
]
Any suggestions please. Thank you in advance.
you must be sure that there is no duplicate of default code in the database
The code works fine, the problem was as Ray Carnes stated, there was a product i had hidden in the past that shared the same product default code with another product in the database
You must check check is no duplicate entry in database. If it is , your constraint will not be create.