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

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

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

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;

}

Аватар
Отменить
Related Posts Ответы Просмотры Активность
0
мая 25
221
1
мая 25
574
4
мая 25
1867
2
мая 25
2035
1
февр. 25
5402