[IMP] diagram :- improve parser code(parse node and arrow field).
bzr revid: ysa@tinyerp.co.in-20100414121217-1yh6uohkjkwl8r8e
This commit is contained in:
parent
ad67123966
commit
4ebbb9fbda
|
@ -1134,21 +1134,31 @@ class orm_template(object):
|
||||||
fields = {}
|
fields = {}
|
||||||
childs = True
|
childs = True
|
||||||
|
|
||||||
|
def encode(s):
|
||||||
|
if isinstance(s, unicode):
|
||||||
|
return s.encode('utf8')
|
||||||
|
return s
|
||||||
|
|
||||||
if node.tag in ('field', 'node', 'arrow'):
|
if node.tag in ('field', 'node', 'arrow'):
|
||||||
if node.get('object'):
|
if node.get('object'):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
views = {}
|
views = {}
|
||||||
|
xml = "<form>"
|
||||||
for f in node:
|
for f in node:
|
||||||
if f.tag in ('field'):
|
if f.tag in ('field'):
|
||||||
node.remove(f)
|
xml += etree.tostring(f, encoding="utf-8")
|
||||||
ctx = context.copy()
|
xml += "</form>"
|
||||||
ctx['base_model_name'] = self._name
|
new_xml = etree.fromstring(encode(xml))
|
||||||
xarch, xfields = self.pool.get(node.get('object')).__view_look_dom_arch(cr, user, f, view_id, ctx)
|
ctx = context.copy()
|
||||||
views[str(f.tag)] = {
|
ctx['base_model_name'] = self._name
|
||||||
'arch': xarch,
|
xarch, xfields = self.pool.get(node.get('object',False)).__view_look_dom_arch(cr, user, new_xml, view_id, ctx)
|
||||||
'fields': xfields
|
views[str(f.tag)] = {
|
||||||
}
|
'arch': xarch,
|
||||||
attrs = {'views': views}
|
'fields': xfields
|
||||||
|
}
|
||||||
|
attrs = {'views': views}
|
||||||
|
view = False
|
||||||
|
fields = views.get('field',False) and views['field'].get('fields',False)
|
||||||
if node.get('name'):
|
if node.get('name'):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
try:
|
try:
|
||||||
|
@ -1268,7 +1278,17 @@ class orm_template(object):
|
||||||
arch = etree.tostring(node, encoding="utf-8").replace('\t', '')
|
arch = etree.tostring(node, encoding="utf-8").replace('\t', '')
|
||||||
|
|
||||||
fields={}
|
fields={}
|
||||||
fields = self.fields_get(cr, user, fields_def.keys(), context)
|
if node.tag=='diagram':
|
||||||
|
if node.getchildren()[0].tag=='node':
|
||||||
|
node_fields=self.pool.get(node.getchildren()[0].get('object')).fields_get(cr, user, fields_def.keys(), context)
|
||||||
|
if node.getchildren()[1].tag=='arrow':
|
||||||
|
arrow_fields = self.pool.get(node.getchildren()[1].get('object')).fields_get(cr, user, fields_def.keys(), context)
|
||||||
|
for key,value in node_fields.items():
|
||||||
|
fields[key]=value
|
||||||
|
for key,value in arrow_fields.items():
|
||||||
|
fields[key]=value
|
||||||
|
else:
|
||||||
|
fields = self.fields_get(cr, user, fields_def.keys(), context)
|
||||||
for field in fields_def:
|
for field in fields_def:
|
||||||
if field == 'id':
|
if field == 'id':
|
||||||
# sometime, the view may containt the (invisible) field 'id' needed for a domain (when 2 objects have cross references)
|
# sometime, the view may containt the (invisible) field 'id' needed for a domain (when 2 objects have cross references)
|
||||||
|
|
Loading…
Reference in New Issue