Odoo Help

Welcome!

This community 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.

4

Unique Internal Reference... [Closed]

By
Luís
on 4/11/13, 3:52 PM 2,944 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

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

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)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

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