Skip to Content
Menu
This question has been flagged
3 Replies
5691 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.

Avatar
Discard
Author

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.

Best Answer

Hi,

try this:

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

Best regards.

Avatar
Discard
Best Answer

Make use of  _sql_constraints unique or use regular expressions.

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 24
2093
2
Dec 23
8623
1
Mar 15
6444
1
Dec 23
25156
3
Sep 24
43962