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

I write a field in product.py:

        'english_name':fields.char('English Name', size=128, select=True),

and I want to add this field in the sale.order.line. If I should write a realted ? I try to write like this in sale.py:

'product_eng_id': fields.related('english_name','product_eng_id', type = "many2one", relation = "product.product" , string = 'english name',store=False),

But it also show the "name" instead of "english_name"..I don't know what's wrong,maybe the relation is not product.product?..My fields.related have some problems?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try this:

'product_eng_name': fields.related('product_eng_id', 'english_name', type='char', string='Product English Name'),
อวตาร
ละทิ้ง
ผู้เขียน

Thanks so much~~

คำตอบที่ดีที่สุด

i think you have added the field 'english_name' in the model 'product.product' and want to add related field in 'sale.order.line'

In the 'sale.order.line' model add

'product_eng_name':fields.related('product_id', 'english_name', type='char', size=64,string='Product English Name'),
อวตาร
ละทิ้ง
ผู้เขียน

Thanks so much~~It can work now

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ม.ค. 18
5740
1
ธ.ค. 23
17450
0
ก.พ. 25
1500
0
ม.ค. 25
1256
Field service upgrade แก้ไขแล้ว
1
ธ.ค. 24
1665