Odoo Help

4

Unique Internal Reference... [Closed]

By
Luís
on 4/11/13, 3:52 PM 3,462 views

The Question has been closed

by
Sudhir Arya (SA)
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()
1
Francesco OpenCode
On 4/12/13, 8:22 AM

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

0
Sudhir Arya (SA)
On 4/11/13, 3:58 PM

You can use _sql_constraints:

Try this:

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

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 4/11/13, 3:52 PM
Seen: 3462 times
Last updated: 3/16/15, 8:10 AM