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

I need to create a One2Many field in Odoo, but using the same model where the field is created. For example.

class WindowForm(models.Model):

        _name= 'window.form'

        doors = fields.One2Many('window.form')

As you can see the One2Many field has the same model of the class where it is declared.

I know that the above declaration is not correct, but that is exactly my doubt. When you define a One2Many field you have to create Many2One field in the other model. So, how can i declare the One2Many?

Thanks in advanced.

アバター
破棄
最善の回答

Hi,

class WindowForm(models.Model):

    _name = 'window.form' 


    parent_id = fields.Many2one('window.form', string="Parent")

    child_ids = fields.One2many('window.form', 'parent_id', string="Lines")


Bye

アバター
破棄
関連投稿 返信 ビュー 活動
1
6月 18
3839
1
2月 16
4287
0
2月 16
4187
1
3月 23
2214
0
12月 22
2857