تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3916 أدوات العرض

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.

 

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أكتوبر 19
4048
2
أكتوبر 19
3505
0
أكتوبر 18
3849
2
يوليو 23
3157
1
يوليو 23
2125