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

I've some problems to address fields.related correctly.

class custom_purchase_order(osv.Model):

_inherit = 'purchase.order'
_columns = {
'x_custom_field_p_o': fields.char('Custom Field', size=64, readonly=False, ondelete='set null', select=True),
    }
custom_purchase_order()

 


class custom_stock_picking_in(osv.Model):
_inherit = 'stock.picking.in'
_columns = {

    'x_custom_field_s_p_i': fields.related('purchase_id', 'x_custom_field_p_o', type='char', relation='purchase.order', readonly=True, store=True, string='Custom Field from Purchase Order'),
    }
custom_stock_picking_in()

 

I only want to show the value of the custom_field_p_o in Incoming Shipments. (It should match to the Purchase ID / Order ID)

I don't get it work.

ERROR: value = value[field] or False TypeError: 'int' object has no attribute '__getitem__'

อวตาร
ละทิ้ง

Hi,
You can watch following video to know about related field in Odoo.
https://youtu.be/A-0uQnJr3QA

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

Code will be:

x_custom_field_s_p_i = fields.Char(string='Field Name', related='purchase_id.x_custom_field_p_o', readonly=True)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 23
2183
2
มี.ค. 15
9474
1
มี.ค. 15
3938
2
ก.พ. 25
1027
0
พ.ค. 24
1381