Skip to Content
Menu
This question has been flagged
1 Reply
4245 Views

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
3
Jul 24
852
1
Mar 22
8411
0
Mar 15
2750
5
Aug 24
42968
2
Apr 24
948