Odoo Help

1

how to make a unique field in a module [Closed]

By
oumaima
on 5/13/13, 3:13 PM 8,793 views

The Question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
on 06/08/2013 08:30:23

Hi,i'm trying to make a unique field in my module but it doesn't work,i tried with _sql_constraints but i still add 2 records with the same cne

myfile.py

enter code here_columns = {

'cne':fields.char('Matricule', size=64,required=True), } _constraints = [('student_name','unique(cne)', 'cne already exists')]

8

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11549
| 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

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 5/14/13, 1:58 AM

Try _sql_constraints in new database. It will work then.

Try with

_sql_constraints = [
    ('cne_unique', 'unique(cne)', 'cne already exists!')
]

Restart your server and create new database.

thank you it work's now;i had to create a new database

oumaima
on 5/14/13, 6:44 AM
7

ClueLogics Technologies Pvt. Ltd.

--ClueLogics Technologies Pvt. Ltd.--
6143
| 6 5 8
Delhi NCR, India
--ClueLogics Technologies Pvt. Ltd.--

 ClueLogics Technologies Pvt Ltd is a Software product and services provider. We are positioned to deliver robust, rapid and reliable Information Technology solutions that work. What we succeed upon is Technology and Technical Expertise. The industry review of ClueLogics has been commendable for the past years as most of its business comes from repeat orders by highly satisfied clients.

ClueLogics Technologies Pvt. Ltd.
On 6/8/13, 4:30 AM

Hi Yes use constraints with your model class just the sibling of _columns and _defaults

type:

 _sql_constraints = [
('your_field_name_unique', 'unique(your_field_name)', 'Can't be duplicate value for this field!')

]

Thanks
Sandeep

ok thank you i will add the help message

oumaima
on 6/8/13, 8:22 AM

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: 5/13/13, 3:13 PM
Seen: 8793 times
Last updated: 3/16/15, 8:10 AM