f_val = f_val[0]
return f_val
a_eval = node.get('eval','')
- idref2 = {}
if a_eval:
idref2 = _get_idref(self, cr, uid, f_model, context, idref)
try:
return unsafe_eval(a_eval, idref2)
except Exception:
- _logger.warning('could not eval(%s) for %s in %s' % (a_eval, node.get('name'), context), exc_info=True)
- return ""
+ logging.getLogger('openerp.tools.convert.init').error(
+ 'Could not eval(%s) for %s in %s', a_eval, node.get('name'), context)
+ raise
+ def _process(s, idref):
+ m = re.findall('[^%]%\((.*?)\)[ds]', s)
+ for id in m:
+ if not id in idref:
+ idref[id]=self.id_get(cr, id)
+ return s % idref
if t == 'xml':
- def _process(s, idref):
- m = re.findall('[^%]%\((.*?)\)[ds]', s)
- for id in m:
- if not id in idref:
- idref[id]=self.id_get(cr, id)
- return s % idref
_fix_multiple_roots(node)
return '<?xml version="1.0"?>\n'\
+_process("".join([etree.tostring(n, encoding='utf-8')
- for n in node]),
- idref)
+ for n in node]), idref)
+ if t == 'html':
+ return _process("".join([etree.tostring(n, encoding='utf-8')
+ for n in node]), idref)
if t in ('char', 'int', 'float'):
d = node.text
if t == 'int':
res = {'name': name, 'url': url, 'target':target}
- 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)
+ id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.act_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','False'))) and id:
- keyword = str(rec.get('keyword','') or 'client_action_multi')
- 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')
if rec.get('action'):
a_action = rec.get('action','').encode('utf8')
- a_type = rec.get('type','').encode('utf8') or 'act_window'
+
+ # determine the type of action
+ a_type, a_id = self.model_id_get(cr, a_action)
+ a_type = a_type.split('.')[-1] # keep only type part
+
icons = {
"act_window": 'STOCK_NEW',
"report.xml": 'STOCK_PASTE',
"wizard": 'STOCK_EXECUTE',
- "url": 'STOCK_JUMP_TO'
+ "url": 'STOCK_JUMP_TO',
+ "client": 'STOCK_EXECUTE',
+ "server": 'STOCK_EXECUTE',
}
values['icon'] = icons.get(a_type,'STOCK_NEW')
+
if a_type=='act_window':
- a_id = self.id_get(cr, a_action)
cr.execute('select view_type,view_mode,name,view_id,target from ir_act_window where id=%s', (int(a_id),))
rrres = cr.fetchone()
assert rrres, "No window action defined for this id %s !\n" \
"Verify that this is a window action or add a type argument." % (a_action,)
action_type,action_mode,action_name,view_id,target = rrres
if view_id:
- cr.execute('SELECT type FROM ir_ui_view WHERE id=%s', (int(view_id),))
- action_mode, = cr.fetchone()
+ cr.execute('SELECT arch FROM ir_ui_view WHERE id=%s', (int(view_id),))
+ arch, = cr.fetchone()
+ action_mode = etree.fromstring(arch.encode('utf8')).tag
cr.execute('SELECT view_mode FROM ir_act_window_view WHERE act_window_id=%s ORDER BY sequence LIMIT 1', (int(a_id),))
if cr.rowcount:
action_mode, = cr.fetchone()
values['icon'] = 'STOCK_EXECUTE'
if not values.get('name', False):
values['name'] = action_name
- elif a_type=='wizard':
- a_id = self.id_get(cr, a_action)
- cr.execute('select name from ir_act_wizard where id=%s', (int(a_id),))
- resw = cr.fetchone()
- if (not values.get('name', False)) and resw:
- values['name'] = resw[0]
- elif a_type=='url':
- a_id = self.id_get(cr, a_action)
- cr.execute('select name from ir_act_url where id=%s', (int(a_id),))
+
+ elif a_type in ['wizard', 'url', 'client', 'server'] and not values.get('name'):
+ a_table = 'ir_act_%s' % a_type
+ cr.execute('select name from %s where id=%%s' % a_table, (int(a_id),))
resw = cr.fetchone()
- if (not values.get('name')) and resw:
+ if resw:
values['name'] = resw[0]
+
+ if not values.get('name'):
+ # ensure menu has a name
+ values['name'] = rec_id or '?'
+
if rec.get('sequence'):
values['sequence'] = int(rec.get('sequence'))
if rec.get('icon'):
groups_value.append((4, group_id))
values['groups_id'] = groups_value
- xml_id = rec.get('id','').encode('utf8')
- self._test_xml_id(xml_id)
- pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
+ pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, rec_id, noupdate=self.isnoupdate(data_node), mode=self.mode, res_id=res and res[0] or False)
if rec_id and pid:
self.idref[rec_id] = int(pid)
if rec.get('action') and pid:
- a_action = rec.get('action').encode('utf8')
- a_type = rec.get('type','').encode('utf8') or 'act_window'
- a_id = self.id_get(cr, a_action)
action = "ir.actions.%s,%d" % (a_type, a_id)
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id)
return ('ir.ui.menu', pid)