Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
7322 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 16
14190
1
thg 2 24
1248
0
thg 1 23
4828
2
thg 11 20
17854
4
thg 12 23
17725