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

I'm trying to add product_id.description_picking to stock.pack.operation(pack_operation_product_ids)

#Form view

<record id="view_stock_picking_form" model="ir.ui.view">

<field name="name">Stock Picking Price Form</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//page/field[@name='pack_operation_product_ids']/tree/field[@name='product_id']" position="after">
<field name="description_picking"/>
</xpath>
</field>
</record>

#Model

class descmoduledo(models.Model):
_inherit ='stock.picking'
#
description_picking = fields.Char(string='Picking Description',store=True,related='product_id.descriptio_picking')

class StockPackOperation(models.Model):
_inherit ='stock.pack.operation'
description_picking = fields.Char(string='Picking Description',store=True,related='product_id.description_picking')

when i install my module it show error 
raise 

TypeError("Type of related field %s is inconsistent with %s" % (self, field))
TypeError: Type of related field stock.pack.operation.description_picking is inconsistent with product.product.description_picking
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Ahmatdanis,

The field that you've created is of the type 'Char' while the field description_product on the model product.product is from the type 'Text'. Just change your field definition from char to text like this:

description_picking = fields.Text(string='Picking Description',store=True,related='product_id.description_picking')

A related field its field type always has to be the same as the original field where you're relating to.

Regards,
Yenthe

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 22
1939
0
เม.ย. 22
2604
3
ก.ย. 21
2802
2
ก.ย. 21
4170
2
ธ.ค. 19
5114