Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
3543 Представления

hi all,

I had 2 Models in single view, first is Form view and second is a Tree view with editable="bottom" (both Models are related with Many2one and One2many fields).

requirement:

the value of field "name" in first model (model.cat) which is in Form view should be copied in a field "parent" of second model (model.subcat) which is in Tree view ( whether user Saved or Not saved yet ).

please help how i can achieve this.

regards

Аватар
Отменить
Лучший ответ

Hi,

You can pass default value from main model to one2many model using the context.


See Sample:

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

See: How to Set default value while creating record from one2many field


Thanks

Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
апр. 23
2742
2
февр. 25
40428
2
нояб. 22
2821
1
февр. 22
7849
2
дек. 21
4105