diff options
| author | Jay (Open ERP) <jvo@tinyerp.com> | 2010-05-20 12:00:44 +0530 |
|---|---|---|
| committer | Jay (Open ERP) <jvo@tinyerp.com> | 2010-05-20 12:00:44 +0530 |
| commit | e3ccef27d33ff83ddbb7bfd3eacc80f8a98bd21d (patch) | |
| tree | f14fb77ab9702c91bcb9309724e5aa63a96ee570 /bin/tools/convert.py | |
| parent | 2669744f4f09ca6ac9219dc91909e895559c74c0 (diff) | |
| parent | fe7673b7ba1f2706b8ed2abe6892ad33211063cd (diff) | |
[BACKPORT] Stable fixes and refactorings to Trunk
bzr revid: jvo@tinyerp.com-20100520063044-sviy1e9pybirhpsw
Diffstat (limited to 'bin/tools/convert.py')
| -rw-r--r-- | bin/tools/convert.py | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 1188f6deaa8..a7e002e1a61 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -26,11 +26,9 @@ import os.path import pickle import re import sys -import time from datetime import datetime from lxml import etree - import ir import misc import netsvc @@ -79,6 +77,7 @@ def _eval_xml(self,node, pool, cr, uid, idref, context=None): return f_val a_eval = node.get('eval','') if a_eval: + import time idref2 = idref.copy() idref2['time'] = time idref2['DateTime'] = datetime @@ -253,6 +252,14 @@ form: module.record_id""" % (xml_id,) self.pool.get(d_model).unlink(cr, self.uid, ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids) + def _remove_ir_values(self, cr, name, value, model): + ir_value_ids = self.pool.get('ir.values').search(cr, self.uid, [('name','=',name),('value','=',value),('model','=',model)]) + if ir_value_ids: + self.pool.get('ir.values').unlink(cr, self.uid, ir_value_ids) + self.pool.get('ir.model.data')._unlink(cr, self.uid, 'ir.values', ir_value_ids) + + return True + def _tag_report(self, cr, rec, data_node=None): res = {} for dest,f in (('name','string'),('model','model'),('report_name','name')): @@ -262,16 +269,17 @@ form: module.record_id""" % (xml_id,) if rec.get(field): res[dest] = rec.get(field).encode('utf8') if rec.get('auto'): - res['auto'] = eval(rec.get('auto')) + res['auto'] = eval(rec.get('auto','False')) if rec.get('sxw'): sxw_content = misc.file_open(rec.get('sxw')).read() res['report_sxw_content'] = sxw_content if rec.get('header'): - res['header'] = eval(rec.get('header')) + res['header'] = eval(rec.get('header','False')) if rec.get('report_type'): res['report_type'] = rec.get('report_type') - res['multi'] = rec.get('multi') and eval(rec.get('multi')) + res['multi'] = rec.get('multi') and eval(rec.get('multi','False')) + xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) @@ -291,12 +299,16 @@ form: module.record_id""" % (xml_id,) id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) - if not rec.get('menu') or eval(rec.get('menu','')): + if not rec.get('menu') or eval(rec.get('menu','False')): keyword = str(rec.get('keyword', 'client_print_multi')) keys = [('action',keyword),('res_model',res['model'])] value = 'ir.actions.report.xml,'+str(id) replace = rec.get('replace', True) self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, res['name'], [res['model']], value, replace=replace, isobject=True, xml_id=xml_id) + elif self.mode=='update' and eval(rec.get('menu','False'))==False: + # Special check for report having attribute menu=False on update + value = 'ir.actions.report.xml,'+str(id) + self._remove_ir_values(cr, res['name'], value, res['model']) return False def _tag_function(self, cr, rec, data_node=None): @@ -313,7 +325,7 @@ form: module.record_id""" % (xml_id,) name = rec.get("name",'').encode('utf8') xml_id = rec.get('id','').encode('utf8') self._test_xml_id(xml_id) - multi = rec.get('multi','') and eval(rec.get('multi','')) + multi = rec.get('multi','') and eval(rec.get('multi','False')) res = {'name': string, 'wiz_name': name, 'multi': multi, 'model': model} if rec.get('groups'): @@ -332,12 +344,16 @@ form: module.record_id""" % (xml_id,) id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) # ir_set - if (not rec.get('menu') or eval(rec.get('menu',''))) and id: + if (not rec.get('menu') or eval(rec.get('menu','False'))) and id: keyword = str(rec.get('keyword','') or 'client_action_multi') keys = [('action',keyword),('res_model',model)] value = 'ir.actions.wizard,'+str(id) replace = rec.get("replace",'') or True self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, string, [model], value, replace=replace, isobject=True, xml_id=xml_id) + elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False): + # Special check for wizard having attribute menu=False on update + value = 'ir.actions.wizard,'+str(id) + self._remove_ir_values(cr, string, value, model) def _tag_url(self, cr, rec, data_node=None): url = rec.get("string",'').encode('utf8') @@ -351,12 +367,16 @@ form: module.record_id""" % (xml_id,) id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.url", self.module, res, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode) self.idref[xml_id] = int(id) # ir_set - if (not rec.get('menu') or eval(rec.get('menu',''))) and id: + if (not rec.get('menu') or eval(rec.get('menu','False'))) and id: keyword = str(rec.get('keyword','') or 'client_action_multi') keys = [('action',keyword)] value = 'ir.actions.url,'+str(id) replace = rec.get("replace",'') or True self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, url, ["ir.actions.url"], value, replace=replace, isobject=True, xml_id=xml_id) + elif self.mode=='update' and (rec.get('menu') and eval(rec.get('menu','False'))==False): + # Special check for URL having attribute menu=False on update + value = 'ir.actions.url,'+str(id) + self._remove_ir_values(cr, url, value, "ir.actions.url") def _tag_act_window(self, cr, rec, data_node=None): name = rec.get('name','').encode('utf-8') @@ -379,11 +399,12 @@ form: module.record_id""" % (xml_id,) uid = self.uid # def ref() added because , if context has ref('id') eval wil use this ref - active_id=str("active_id") # for further reference in client/bin/tools/__init__.py + active_id = str("active_id") # for further reference in client/bin/tools/__init__.py def ref(str_id): return self.id_get(cr, None, str_id) context = eval(context) +# domain = eval(domain) # XXX need to test this line -> uid, active_id, active_ids, ... res = { 'name': name, |
