跳至内容
菜单
此问题已终结
1 回复
5256 查看

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?

形象
丢弃
最佳答案

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" />

形象
丢弃
相关帖文 回复 查看 活动
3
7月 24
3058
1
3月 22
9791
0
3月 15
3725
2
2月 25
5812
1
12月 24
1386