This question has been flagged

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

Avatar
Discard
Best Answer

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.

Avatar
Discard
Author

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