[IMP] Assosiation: Optimize code of field_view_get

bzr revid: aag@tinyerp.com-20110727132517-j32ctm6550zn7f4w
This commit is contained in:
Atik Agewan (OpenERP) 2011-07-27 18:55:17 +05:30
parent f2d03121ab
commit e96061b31a
1 changed files with 7 additions and 12 deletions

View File

@ -21,6 +21,7 @@
from lxml import etree
from osv import fields, osv
class profile_association_config_install_modules_wizard(osv.osv_memory):
_inherit = 'base.setup.installer'
@ -39,18 +40,12 @@ class profile_association_config_install_modules_wizard(osv.osv_memory):
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
res = super(profile_association_config_install_modules_wizard, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
doc = etree.XML(res['arch'])
nodes_gtd = doc.xpath("//field[@name='project_gtd']")
nodes_exp = doc.xpath("//field[@name='hr_expense']")
count_gtd = 0.0
count_exp = 0.0
for node in nodes_gtd:
count_gtd = count_gtd + 1
if count_gtd > 1 :
node.set('invisible', '1')
for node in nodes_exp:
count_exp = count_exp + 1
if count_exp > 1 :
node.set('invisible', '1')
for module in ['project_gtd','hr_expense']:
count = 0
for node in doc.xpath("//field[@name='%s']" % (module)):
count = count + 1
if count > 1:
node.set('invisible', '1')
res['arch'] = etree.tostring(doc)
return res