Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1232 Prikazi

Is it possible to have a common form to create a child model depending on the field "child_type" selected?

classParent(models.Model):
  _name = 'parent'  
    child_type= fields.Selection(['childA', 'childB'], 'Type') 

classChildA(models.Model):
  _name = 'childA'
  _inherits = {'parent': 'parent_id'}  
    fieldA = fields.Char('FieldA', required=True)

class ChildB(models.Model):
  _name = 'childB'
  _inherits = {'parent': 'parent_id'}  
    fieldB = fields.Char('FieldB', required=True)
Avatar
Opusti