Skip to Content
Menu
This question has been flagged
1815 Views

tried to anwer a question about that but y couldn't so y post it as a question but with answer, maybe usefull for some one:

Hi, you have 2 ways to do that:

1.- Create by hand the relation. Remember that in ERM (Entity-Relation Model) a many2many relation is split into 2 one2many relation, it means:

teacher <<----------->> class (m:n relation) its the same of :

teacher <-------->> teacher_class<<--------->class   (that is what odoo internally do) so, in teacher_class model you can create any field you want

2.- using Odoo inhetitance model:

Model inheritance in Odoo has 3 possibilities

in case of Delegation inheritance its the same of creating a one2many relation between base and extended class, so it can be used too for instance

class TeacherClass(models.Model)

    _name = 'teacher_class'

    _inherits = {'class': 'class_id}

it means that teacher_class model extends de class model and related it by class_id field

then you create on teacher a field like:

class_ids = fields.One2many('teacher_class','teacher_id')

and in teacher_class al fields you need as part of many2many relation.

hope it helps you.



Avatar
Discard