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

Hello Community

I have a problem , i have on2many tree-view with multiple columns(fields) , i want some fields to be shown under Condition (A) and the others on Condition(B)  without hiding the Fields in condition A  , i tried the attrs it didn't work I've tried some solution like this : invisible="context.get('type') == 'out_invoice' "   but it work only one if i change the condition later the fields still hiding 

아바타
취소
베스트 답변

hello 

you can hide column using the following example. this example available in sale order. 

you can try like this

<field name="qty_invoiced"attrs="{'column_invisible': [('parent.state', 'not in', ['sale', 'done'])]}"/>

아바타
취소
베스트 답변
This is for Account Move line 
set as per your requiremt 
@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
res = super(AccountMoveLine, self).fields_view_get(view_id, view_type, toolbar=toolbar, submenu=submenu)
print ('----type---', view_type)
if view_type == 'tree':
print ('OOOOOOOOOOOOOOOOOO')
doc = etree.XML(res['arch'])
partner_string = _('Supplier')
for node in doc.xpath("//field[@name='partner_id']"):
node.set('string', partner_string)
for node in doc.xpath("//field[@name='name']"):
node.set('invisible', 'True')
doc.remove(node)

res['arch'] = etree.tostring(doc)
return res
아바타
취소
베스트 답변

You have to do it by inheriting the fields_view_get function.

This example is for sale order line view, just modify to meet you requirements to hide product_id column

@api.model   

def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
        res = super(yourClassName, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,                     submenu=submenu)

         if res['name'] == 'thisIsTheIDofYourView': #to filter your view
         doc = etree.XML(res['fields']['order_line']['views']['tree']['arch'])

         if CONDITION A:
                for node in doc.xpath("//field[@name='product_id']"):
                    node.set('invisible', '0')                   

                    setup_modifiers(node)

        res['fields']['order_line']['views']['tree']['arch'] = etree.tostring(doc)

return res

아바타
취소
작성자

Thank you Juan for your answer , unfortunately it didn't work in my case