Reputation: 155
hello how can I do related in fields :
class etude(models.Model):
_name= 'etude.risque'
incendie = fields.Integer('Suppresseur Anti_Incendie', related='anti_incendie')
second class
class risque(models.Model):
_name='risques.risque'
_rec_name='nom_risque'
anti_incendie = fields.Many2one('risques.incendie', string="Suppresseur Anti_Incendie",required=True)
how can I do incendie in class etude related to anti_incendie in class risque
Upvotes: 1
Views: 207
Reputation: 1538
you need to declare a many2one field with risque class:
risque_id = fields.Many2one('risques.risque', 'Risque')
and then you need to create your related class using the relation created. If the field you want to relate is a many2one you need to create a many2one related field:
incendie = fields.Many2one(related='risque_id.anti_incendie')
I hope this help you.
Upvotes: 1