コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
147 ビュー

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")
アバター
破棄
関連投稿 返信 ビュー 活動
0
10月 25
8
0
10月 25
137
0
10月 25
210
0
10月 25
3
1
10月 25
255