Odoo Help

0

Add Unique Field Like Id

By
alex
on 9/29/16, 7:24 AM 558 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.

alex
on 9/29/16, 9:24 AM
2

Bejaoui Souheil

--Bejaoui Souheil--
1051
| 2 1 5
Rennes, France
--Bejaoui Souheil--

Odoo developer,  functional and technical consultant

souheil_bejaoui@hotmail.fr

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

Hi,

try this:

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

Best regards.

0
Annadurai
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.

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

1 follower(s)

Stats

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