Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
9900 Zobrazení

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.

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvn 18
3845
1
úno 16
4301
0
úno 16
4191
1
bře 23
2226
0
pro 22
2866