Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
When I create a custom model in the web GUI, how can I mark a field as "unique", so that the database will never create a second row with the same field value?
You can only do this when you create your field via Python.
_sql_constraints = [ ('field_unique', 'unique(field)', 'Choose another value - it has to be unique!') ]
Note that if there are existing records for the model in the database, then any field values have to be unique, or this will fail and OpenERP will do nothing to enforce the constraint for new records.
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
|Asked: 6/26/13, 3:32 PM|
|Seen: 6499 times|
|Last updated: 3/16/15, 8:10 AM|