Odoo Help


Add Unique Field Like Id

on 9/29/16, 7:24 AM 1,049 views

I Have an Module which is import the external data. I want to add that external id in my selected model's unique field.

model_id = fields.Many2one('ir.model', 'Model', required=True)

if i select any model than external id should be store in unique field. here,how to create unique field for every selected model.

on button click i have import external data in selected model here problem is that i don't have any field to store external id. I want to add that external id in my selected model's unique field.

on 9/29/16, 9:24 AM

Bejaoui Souheil

--Bejaoui Souheil--
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant


Bejaoui Souheil
On 9/29/16, 9:09 AM


try this:

_sql_constraints = [('unique_id','UNIQUE(model_id)',"Message error to be displayed"),]

Best regards.


On 9/30/16, 2:02 AM

Make use of  _sql_constraints unique or use regular expressions.

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.


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

1 follower(s)


Asked: 9/29/16, 7:24 AM
Seen: 1049 times
Last updated: 10/1/16, 4:36 AM