Add unicity of default_code, because I think it's important to have that by default.

This commit is contained in:
Alexis de Lattre
2016-11-17 18:51:34 +01:00
committed by Raphaël Valyi
parent 8cc2fe66f4
commit 1bd86ce02a

View File

@@ -11,3 +11,13 @@ class ProductProduct(models.Model):
price_history_ids = fields.One2many(
'product.price.history', 'product_id',
string='Product Price History')
_sql_constraints = [(
# Maybe it could be better to have a constrain per company
# but the company_id field is on product.template,
# not on product.product
# If it's a problem, we'll create a company_id field on
# product.product
'default_code_uniq',
'unique(default_code)',
'This internal reference already exists!')]