Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
21084 Visualizzazioni

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

Avatar
Abbandona

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.

Risposta migliore

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

Avatar
Abbandona
Autore

Thank you , it is correct

Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
nov 23
1423
1
set 23
3355
2
ott 22
21338
1
giu 22
6308
1
giu 22
3115