跳至內容
選單
此問題已被標幟
1 回覆
5243 瀏覽次數

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
3029
1
3月 22
9777
0
3月 15
3717
2
2月 25
5791
1
12月 24
1372