How to set default value from parent form in one2many field while creating records in one2many field, before saving parent form
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
4
Replies
20348
Views
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.?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Nov 23
|
924 | ||
|
1
Sep 23
|
2575 | ||
|
2
Oct 22
|
19953 | ||
|
1
Jun 22
|
5060 | ||
|
1
Jun 22
|
2481 |
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.