Odoo Help

Welcome!

This community 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.

0

Add Unique Field Like Id

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

Bejaoui Souheil

--Bejaoui Souheil--
808
| 2 1 4
Sousse, Tunisia
--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.

Your Answer

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

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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