Can i pass data from many2one field automatically to a one2many field exist in different classes and in different forms using the method on_change_with_fieldName or another scenario to achieve my goal?!

I Have a form 1 with ClassA and has two fields (the field_b and the field_c)

the code:

class ClassA(DeactivableMixin, ModelSQL,ModelView, MultiValueMixin):
        __name__ = 'incidents.classa'
        field_b = fields.Many2One('incidents.class_b','shipFR',ondelete='CASCADE')
       field_c = fields.Many2One('incidents.class_c', 'Suradic',ondelete='CASCADE') 

And this is the code of the class called by the field_c :

 class ClassC(DeactivableMixin, ModelView, ModelSQL, MultiValueMixin):

    __name__ = 'incidents.class_c'

    convention  = fields.Char("Convention ")
    name = fields.Char("Name")
    def get_rec_name(self,convention ):
        return self.convention

code of the ClassB called by the field_b that exist in another form2

class ClassB(DeactivableMixin, ModelSQL, ModelView, MultiValueMixin):

    __name__ = 'incidents.class_b'

    protocol = fields.One2Many('incidents.class_d','link_classB_D','Protocole Ariva')

in this ClassB i Have a problem on the field “protocol” which point on One2many relation(has 3 fields) , one of this field i defined it ''field_e" , i want it to take the content of another field point on many2one relation and exist in another class (this field is the field_c from the ClassA (i was put the code on the top of description).

and this is the ClassD which is called by the field “protocol” talking about the one2many relation table and has 3 fields , one of them i define it by ‘’ field_e" and i want it to take as i say the content of of another field which is field_c point on many2one relation :

class ClassD(DeactivableMixin, ModelView, ModelSQL, MultiValueMixin):

    __name__ = 'incidents.class_d'
    
    link_classB_D = fields.Many2One('incidents.class_b', ondelete='CASCADE', states=STATES depends=DEPENDS)
    
    field_e = fields.Char("Seam")  

    @fields.depends('field_e')
    def on_change_field_e(self):
       pool = Pool()
       parameterup = Pool().get('incidents.classa')
       parameterups, = parameterup.search([
                ('field_c', '=', 'field_c.convention'),
                    ], limit=1)
       for line in self.field_e:
                line.field_e = parameterups.field_e

My problem here on how correctly i must call the field that point many2one relation and that exist in ClassA to make one field from the 3 fields that Affiliates to table one2many and exist on ClassD take the content of it.

Ps: the field that point on the relation one2many and the field point point on the relation many2one they are from different classes linked by another class.

i tried to do that with the method on_change_field_e but nothing shown and still empty
image

Thanks.

I read too much field_A, B, C, D, that I get lost between all relations :exploding_head: :exploding_head:

I did not understand what you are trying to achieve nor how all the models are linked together.

I’m sorry but I’m unable to give any tip without a clarification on your doubts. Could you please explain what are you trying to achieve?

Sorry i just put the classes that are linked to the problem i thought like that i make things more clear to help me,
My goal is to pass data automatically from field point on many2one relation to a field exist on one2many relation table ( the two fields are from different form and different classes).

i will explain , i have the field “protocol” is exist in ClassB is talking about the one2many relation table ,which is call the classD , and in this classD , i have 3 fields , one of them that is the defined by field_e i want this field_e that exist in the table one2many take the content of another field many2one defined by field_c that exist in another ClassA
and not in the same form.

like that i was define the field_e who belongs to the one2many table and i have did a function “on_change” to make this field take the content to the field_c

 field_e = fields.Char("Seam")  

    @fields.depends('field_e')
    def on_change_field_e(self):
       pool = Pool()
       parameterup = Pool().get('incidents.classa')
       parameterups, = parameterup.search([
                ('field_c', '=', 'field_c.convention'),
                    ], limit=1)
       for line in self.field_e:
                line.field_e = parameterups.field_e

i coded the field by the method on_change but nothing shown on the table one2many .
the field_e that i want it to take the content of the field_c that point on many2one relation and exsit in another class is marked with blue ( in the screenshot stayed empty.