Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5247 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ก.ค. 24
3031
1
มี.ค. 22
9777
0
มี.ค. 15
3717
2
ก.พ. 25
5793
1
ธ.ค. 24
1374