diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 5bd4a98af83..b10de57859e 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -124,6 +124,13 @@ def escape(x): return x.replace('\\/', '/') class xml_import(object): + + def _test_xml_id(self, xml_id): + id = xml_id + if '.' in xml_id: + base, id = xml_id.split('.') + if len(id) > 64: + self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id) def _tag_delete(self, cr, rec, data_node=None): d_model = rec.getAttribute("model") d_search = rec.getAttribute("search") @@ -150,8 +157,7 @@ class xml_import(object): res['header'] = eval(rec.getAttribute('header')) res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi')) xml_id = rec.getAttribute('id').encode('utf8') - if len(xml_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id) + self._test_xml_id(xml_id) id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode) self.idref[xml_id] = id if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')): @@ -171,8 +177,7 @@ class xml_import(object): model = rec.getAttribute("model").encode('utf8') name = rec.getAttribute("name").encode('utf8') xml_id = rec.getAttribute('id').encode('utf8') - if len(xml_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id) + self._test_xml_id(xml_id) multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi')) res = {'name': string, 'wiz_name': name, 'multi':multi} @@ -190,8 +195,7 @@ class xml_import(object): def _tag_act_window(self, cr, rec, data_node=None): name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8') xml_id = rec.getAttribute('id').encode('utf8') - if len(xml_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id) + self._test_xml_id(xml_id) type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window' view_id = False if rec.hasAttribute('view'): @@ -238,8 +242,7 @@ class xml_import(object): def _tag_menuitem(self, cr, rec, data_node=None): rec_id = rec.getAttribute("id").encode('ascii') - if len(rec_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id) + self._test_xml_id(rec_id) m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8'))) pid = False for idx, menu_elem in enumerate(m_l): @@ -290,8 +293,7 @@ class xml_import(object): g_ids.extend(self.pool.get('res.groups').search(cr, self.uid, [('name', '=', group)])) values['groups_id'] = [(6, 0, g_ids)] xml_id = rec.getAttribute('id').encode('utf8') - if len(xml_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id) + 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, idx==len(m_l)-1, mode=self.mode, res_id=res and res[0] or False) elif res: # the menuitem already exists @@ -320,8 +322,7 @@ class xml_import(object): model = self.pool.get(rec_model) assert model, "The model %s does not exist !" % (rec_model,) rec_id = rec.getAttribute("id").encode('ascii') - if len(rec_id) > 64: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id) + self._test_xml_id(rec_id) # if not rec_id and not data_node.getAttribute('noupdate'): # print "Warning", rec_model