콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
584 화면

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;

}

아바타
취소
관련 게시물 답글 화면 활동
1
6월 25
605
3
5월 25
2354
1
5월 25
761
4
5월 25
2048
1
2월 25
5616