Odoo Help

4

Unique Internal Reference... [Closed]

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

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()
1

Francesco OpenCode

--Francesco OpenCode--

3709
| 6 8 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 (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
10941
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

Top 10 Odoo contributor On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
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: 3780 times
Last updated: 3/16/15, 8:10 AM