コンテンツへスキップ
メニュー
この質問にフラグが付けられました
4 返信
21093 ビュー

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.?

アバター
破棄
関連投稿 返信 ビュー 活動
0
11月 23
1429
1
9月 23
3363
2
10月 22
21357
1
6月 22
6318
1
6月 22
3120