Hello my friends,
I would like to create a new records of class "B" from function. This record have relation Many2one with another class "A".
The class "A" have One2many relation with the class "B". My creation function is as follows :
self.env['affichage2.sensor_stock'].create({
'sensor_type': sensorconfig,
'serial_capture': self.internal_Serial,
'pack_id': self.public_id,
})
The 'pack_id' of the class "B" is declared as follows :
pack_id = fields.Many2one('affichage2.pack_stock', string='Pack de capture')
The 'public_id' of class "A" is declared as follows :
public_serial = fields.Char(string="Public_Serial", required=True)
The class "A" is named by the "public_serial" field as follows : _rec_name = 'public_serial'