Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
4119 Zobrazení

What I wanted is to parse the xml data using Element tree.
Can you give me some example on how to apply the etree?

Avatar
Zrušit
Nejlepší odpověď

Hi, 

As per the etree code you can import the etree and finding of the xml arch, in those cases it will be using full.

import xml.etree.ElementTree as xee
from lxml import etree

view_id = self.env.ref('model.model_view_name')
view_arch = str(view_id.arch_base)
doc = xee.fromstring(view_arch)
field_list = []
field_list_1 = []
for tag in doc.findall('.//field'):
field_list.append(tag.attrib['name'])
 
if 'attrs' in tag.attrib or not 'invisible' in tag.attrib['attrs']:
field_list_1.append(tag.attrib['name'])
 
//You can add your own conditions here 
 

model_id = self.env['ir.model'].sudo().search(
[('model', '=', 'model_name')])
return [('model_id', '=', model_id.id), ('state', '=', 'base'),
('name', 'in', field_list)]

Regards

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
srp 24
1002
1
bře 15
4293
0
srp 24
4
3
bře 24
26130
0
lis 16
5044