Skip to Content
Menu
This question has been flagged
2 Replies
3001 Views

Hello Community

i have a problem i try to create a related field from an existing related field :

'related_fieldv7': fields.related('field1_id', 'field2_id', type="many2one", relation="model", string="Blabla Field", readonly=True),

i want to create a new related field based on the precedent using api v8

Avatar
Discard
Best Answer

Why ?

Why you want create relation to the field already related to something ? (if "primary" field will be empty all related fields will be, if you change value in the last field how will it behave?)


On the other hand you should create relation as normal i guess regardless of the existing relation to the primary/first field.



Avatar
Discard
Best Answer

You can do something like this:

partner_id = fields.Many2one('res.partner','Partner',related='invoice_id.partner_id', store=True)
vat = fields.Char('Vat', related='partner_id.vat', store=True)
Avatar
Discard