1

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

Guesmi
  • 155
  • 1
  • 9
  • Possible duplicate of [related field on odoo?](https://stackoverflow.com/questions/28452805/related-field-on-odoo) – forvas Nov 20 '17 at 16:09

1 Answers1

1

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.

Dayana
  • 1,500
  • 1
  • 16
  • 29