Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
5242 Visninger

Let's say I have

class A(models.Model):    
_name = "A"
    field_a = fields.Many2one('B')


class B(models.Model):
_name = "B"
    field_b = fields.Char()


On a form which model is A I need to render field_b. I tried like this:

<field name="field_a.field_b" /> but with no luck


What is the correct way to do this?

Avatar
Kassér
Bedste svar

You can't write in this format in xml field_a.field_b
You can use related fields to achieve your goal

example

class A(models.Model):    
_name = "A"
    field_a = fields.Many2one('B')
   field_b_in_a = fields.Char(related='field_a.field_b')

and in xml add

<field name="field_b_in_a" />

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
jul. 24
3029
1
mar. 22
9777
0
mar. 15
3717
2
feb. 25
5789
1
dec. 24
1372