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

How to set default value from parent form in one2many field while creating records in one2many field, before saving parent form

อวตาร
ละทิ้ง

To get parent value in one2many we may use context in XML.

Reference: https://goo.gl/XXg5D3

There is a complete guide about context hope this will helps you and others.

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

Hi,

Using context you can achieve it.


See the sample code,

<field name="timesheet_ids" context="{'default_project_id': project_id}">
<tree editable="bottom" string="Timesheet Activities" default_order="date">
<field name="date"/>
<field name="user_id" invisible="1"/>
<field name="employee_id" required="1"/>
<field name="name"/>
<field name="unit_amount" string="Duration" widget="float_time"/>
<field name="project_id" invisible="1"/>
</tree>
</field>


Here,

context="{'default_field_in_one2many': field_in_parent}"


Thanks

อวตาร
ละทิ้ง
ผู้เขียน

Thank you , it is correct

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

How we can pass custom one2many field to sale.order.line one2many field please.?

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 23
1426
1
ก.ย. 23
3358
2
ต.ค. 22
21354
1
มิ.ย. 22
6314
1
มิ.ย. 22
3117