Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie

I am trying to achieve a parent-child object relationship where the child is optional.  Many2one should accomplish this but does not.  When I save the parent, All child records are created despite the "store" and "required" attributes being set to False.

class Parentobject(models.Model):
    _name = 'myapp.parentobject'
    _description = "Parent Object"
    _inherits = {
        'myapp.firstobj':'firstobj_id',
        'myapp.secondobj':'secondobj_id',
  
    }
    firstobj_id = fields.Many2one('myapp.firstobj', required=True, ondelete='cascade')
    secondobj_id = fields.Many2one('myapp.secondobj', store=False, required=False)
With the code above, saving parent (with or without firstobj) causes a record to be created in firstobj and secondobj tables.  This prevents access control from being established differently for parent and both child objects.  All three need "create" for the user who creates the parent, and if there will be any changes to ANY child object, then all child objects need "write" permission.

My access control was set using the Odoo settings (community/docker edition) for groups.

 

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 19
4043
2
paź 19
3502
0
paź 18
3839
2
lip 23
3150
1
lip 23
2111