Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
150 Представления

How Can I Setup One to One a relationship Between Two Models in odoo enterprise 

And How Can I Setup Unique Constraint on a field in odoo enterprise 

Аватар
Отменить
Автор Лучший ответ

Is we can't set-up even unique field constraints in odoo I have odoo enterprise plan hosted on odoo standard hosting, What i want is that instead of editing the base model like contacts i want to store many additional information of a contact, i create another model and create a relationship with contact model, but here the problem is i can't set-up one to one relationship, Only one to many, that's the issue, due to this I can't view contact basic details in my second model using related field 


2. My next question is to how can I Setup Unique  constraint on a. Field or something similar so when user enters the value and if the value exists in database it don't allow new creation of updation

Аватар
Отменить
Лучший ответ

Since you say "setup" and "configuration" - you can't do this in Odoo Studio - or with an Odoo Online Standard plan.

And in general: ORM of Odoo does not have a One2one relationship field type. What you usually would do is to create a Many2one on one model and a One2many relationship on the other model. Then, on that other model, you'd create a computed Many2one relationship back to the first model (<- this is the part you wouldn't be able to do in Studio).

When you want to develop in Odoo, you will not get around reading https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html as a whole.

Constrains are described here as well: https://www.odoo.com/documentation/19.0/developer/reference/backend/orm.html#constraints-and-indexes

class AModel(models.Model):
    _name = 'a.model'
    _my_check = models.Constraint("CHECK (x > y)", "x > y is not true")
Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
окт. 25
8
0
окт. 25
138
0
окт. 25
210
0
окт. 25
3
1
окт. 25
256