Hi everyone
I'm trying to build a view using the fields_view_get method. To make the view adapt to the specific record i would like to hide some of the field groups by adding attrs="{'invisible'.....}".
Inspecting the view in the application reveals that the xml is built correctly, but still somehow the groups don't accept the invisible property and stay visible all the time, even if i set 'invisible' to 1.
This here is the code:
@api.model
deffields_view_get(self, view_id, view_type=False, context=None, toolbar=False, submenu=False):
res = super(Equipment, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)print("VID: ", view_id)
if view_type=='form':
print("HELLO WORLD WFWEFWW")print(self.env.context)
doc = ET.XML(res['arch'])
node = doc.findall(".//page[@name='additional_fields']")[0]
cat_list = self.env['maintenance.equipment.category'].search([])
group = ET.Element('group')node.append(group)
for cat in cat_list:
cat_group = ET.Element('group')
cat_group.set('string',cat.name)
cat_id = str(cat.id)
invisible_string = "{'invisible':[('cat_id_nr','!=','2')]}"
cat_group.set("attrs",invisible_string)
group.append(cat_group)
field_list = cat.test
for field in field_list:
print(field.name, "\n")
el = ET.Element('field')
el.set('name',field.name)
cat_group.append(el)
ET.indent(node, space="\t", level=0)
res['arch'] = ET.tostring(doc)
return res
I thank you in advance for your help!