Help

Unique Internal Reference...

Closed
Avatar
Luís

The question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
on 04/18/2013 05:24:30

Hi,

I need that the field "Internal Reference" of products to be a field unique. Anyone help me?

mymodule.py

class product_product(osv.osv):
    _inherit = "product.product"
    _name = "product.product"
    _sql_constraints = [
        ('code', 'unique(code)', 'Product Reference must be unique!'),
    ]
product_product()
Avatar
Discard
2 Answers
1
Best Answer

Your code must be:

class product_product(osv.osv):
    _inherit = "product.product"
    _name = "product.product"
    _sql_constraints = [
        ('default_code', 'unique(default_code)', 'Product Reference must be unique!'),
    ]
product_product()

The right field for Internal Reference is default_code

Avatar
Discard
1

You can use _sql_constraints:

Try this:

_sql_constraints = [
    ('default_code_uniq', 'unique(default_code)', 'Product Reference must be unique!'),
]
Avatar
Discard