[FIX] tools: re-added html2text import, because of its use in ir_mail_server. Not...
[odoo/odoo.git] / openerp / tools / convert.py
index 36f560b..12ed269 100644 (file)
@@ -134,14 +134,14 @@ def _eval_xml(self, node, pool, cr, uid, idref, context=None):
                     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:
@@ -386,18 +386,8 @@ form: module.record_id""" % (xml_id,)
 
         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')
@@ -591,7 +581,11 @@ form: module.record_id""" % (xml_id,)
 
         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',
@@ -601,8 +595,8 @@ form: module.record_id""" % (xml_id,)
                 "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" \
@@ -627,9 +621,8 @@ form: module.record_id""" % (xml_id,)
                     values['icon'] = 'STOCK_EXECUTE'
                 if not values.get('name', False):
                     values['name'] = action_name
-            
+
             elif a_type in ['wizard', 'url', 'client', 'server'] and not values.get('name'):
-                a_id = self.id_get(cr, a_action)
                 a_table = 'ir_act_%s' % a_type
                 cr.execute('select name from %s where id=%%s' % a_table, (int(a_id),))
                 resw = cr.fetchone()
@@ -667,9 +660,6 @@ form: module.record_id""" % (xml_id,)
             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)