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

i had added two fields to the stock.picking model, 

sales_order_id = fields.Many2one('sale.order', 'Order')
client_ref = fields.Char(related='sales_order_id.client_order_ref')

i want to get the value of the client_order_ref from sale.order in an automatically manner, 

so that i tired this domai

 <record id="xxxxxxxx" model="ir.ui.view">
<field name="name">xxxxxxxxx</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="sales_order_id"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='user_id']" position="after">
    <field name="sales_order_id"/>
    <field name="client_ref" domain="[('sales_order_id', '=', 'origin')]"/>
but i still have to manually give a value to sales_order_id in order to get the client_ref

appropriate value 

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

1) Domain doesn't work for char fields
2) As the sale_id field already exists in stock.picking table
change your fields as below

client_ref = fields.Char(related='sale_id.client_order_ref')
sales_order_id = fields.Many2one('sale.order', 'Order') # No need to add this field
อวตาร
ละทิ้ง
ผู้เขียน

thanks, i didn't give attention to the sale_id field, you save my day

Related Posts ตอบกลับ มุมมอง กิจกรรม
One2many field domain not working แก้ไขแล้ว
2
ธ.ค. 21
6164
display list of product based on domain แก้ไขแล้ว
6
ส.ค. 20
7442
How to get current user in attrs? แก้ไขแล้ว
1
ธ.ค. 19
13399
naked domain set up แก้ไขแล้ว
3
ก.ค. 25
4235
0
พ.ค. 25
851