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.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 6/26/13, 3:32 PM|
|Seen: 5412 times|
|Last updated: 3/16/15, 8:10 AM|