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

Hello everybody, I would like to know if is possible that a one2many field shows differents tree views depending the value of a field, something like this:


<field name="fechas_infraestructuras" context="{'default_actividades_propias': id, 'default_x_ubicacion_actividad': x_ubicacion_actividad}" string="Detalles">

<tree string="Fechas" default_order="x_fecha_inicio" attrs="{'invisible': [('x_ubicacion_actividad', '=', 'exterior')]}">

<field name="x_fecha_inicio"/>

<field name="x_fecha_fin"/>

<field name="x_hora_inicio"/>

<field name="x_hora_fin"/>

<field name="x_instalaciones_usadas"/>

<field name="x_requisitos"/>

<field name="state" invisible="1"/>

<field name="x_ubicacion_actividad"/>

</tree>

(Now another tree view but with different fields)

<tree string="Fechas" default_order="x_fecha_inicio" attrs="{'invisible': [('x_ubicacion_actividad', '=', 'interior')]}">

<field name="x_fecha_inicio"/>

<field name="x_fecha_fin"/>

<field name="x_hora_inicio"/>

<field name="x_hora_fin"/>

<field name="x_personal_iamz"/>

<field name="x_requisitos"/>

<field name="state" invisible="1"/>

<field name="x_ubicacion_actividad"/>

</tree>

</field>


" x_ubicacion_actividad " is a selection field with 2 values ('interior' and 'exterior'), then I want show one of the tree views when  x_ubicacion_actividad is 'interior' and the other one if  x_ubicacion_actividad is 'exterior'.


Is that possible? Thanks!!!

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

You can achieve using one alternative solution.

You need to create 2 one2many fields and add domain in each field.

Ex:

field_1=fields.One2many('model','field_name',domain=[('x_ubicacion_actividad','=','interior')])

field_2=fields.One2many('model','field_name',domain=[('x_ubicacion_actividad','=','exterior')])

After that add both field in the view and create inline tree view also visible field based on attrs.

Аватар
Отменить
Автор

Thank you so much!! It's a great idea!

Related Posts Ответы Просмотры Активность
1
янв. 16
14175
1
февр. 24
1219
0
янв. 23
4784
2
нояб. 20
17810
4
дек. 23
17690