Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
180 Vistas

I am trying to add code fields to the tree view dynamically based on another column. And it works fine, but a columns that should not be visible is there present. If I statically define it in xml, it is is fine, but with python it appears I need this columns as it is compute field that checks if result is lower then target. 

for node in doc.xpath(xpath):

                for i in range(2, visible_count + 1):

                    fname_target = f'target_build_{i}'

                    fname_comp = f'results_from_build_{i}_comp'

                    fname_result = f'results_from_build_{i}'


                    # Always add to res['fields'] if not present

                    for fname in (fname_target, fname_comp, fname_result):

                        if fname in self._fields and fname not in res['fields']:

                            res['fields'][fname] = self.fields_get([fname])[fname]


                    # Inject target_build_X

                    field_target = etree.Element("field", name=fname_target)

                    field_target.set('class', 'target-column')

                    node.append(field_target)


                    # Inject results_from_build_X_comp as hidden field

                    field_comp = etree.Element("field", name=fname_comp)

                    field_comp.set('invisible', '1')

                    node.append(field_comp)


                    # Inject results_from_build_X with decoration

                    field_result = etree.Element("field", name=fname_result)

                    field_result.set('class', 'result-column')

                    field_result.set('decoration-danger', f'{fname_comp}==True')

                    node.append(field_result)


            res['arch'] = etree.tostring(doc, encoding='unicode')

        return res

Avatar
Descartar
Autor Mejor respuesta

I  managed to resolve by myself, with custom css:

.o_list_view th[data-name$="_comp"],

.o_list_view td[data-name$="_comp"],

.o_list_view th[name$="_comp"],

.o_list_view td[name$="_comp"] {

    display: none !important;

}

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
may 25
210
1
may 25
573
4
may 25
1866
2
may 25
2032
1
feb 25
5394