From b68138961f63468bc73eede4f72b13f64266e5f0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Mon, 30 Aug 2010 12:48:06 +0300 Subject: [PATCH 1/2] convert: When loading menu, don't match by name It is safer to create duplicate menus than assume the same name is the same menu. Solved strange case with 'Manufacturing', where it would falsely identify the 'Manufacturing/Manufacturing' as its parent, and thus create a recursive menu. If we are parsing the 'a/b/c' name syntax, we have to ommit "c" from parent search. Conflicts: bin/tools/convert.py bzr revid: p_christ@hol.gr-20100830094806-3d4flzmp6vazdhtb --- bin/tools/convert.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index d9b663ae7a2..1ec4d223601 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -523,29 +523,29 @@ form: module.record_id""" % (xml_id,) m_l = map(escape, escape_re.split(rec.get("name",'').encode('utf8'))) values = {'parent_id': False} - if not rec.get('parent'): + if rec.get('parent', False) is False: pid = False + res = None + values['name'] = m_l[-1] + m_l = m_l[:-1] # last part is our name, not a parent for idx, menu_elem in enumerate(m_l): if pid: cr.execute('select id from ir_ui_menu where parent_id=%s and name=%s', (pid, menu_elem)) else: cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,)) res = cr.fetchone() - if idx==len(m_l)-1: - values = {'parent_id': pid,'name':menu_elem} - elif res: + if res: pid = res[0] - xml_id = idx==len(m_l)-1 and rec.get('id','').encode('utf8') - try: - self.pool.get('ir.model.data')._update_dummy(cr, self.uid, 'ir.ui.menu', self.module, xml_id, idx==len(m_l)-1) - except: - self.logger.notifyChannel('init', netsvc.LOG_ERROR, "module: %s xml_id: %s" % (self.module, xml_id)) else: # the menuitem does't exist but we are in branch (not a leaf) self.logger.notifyChannel("init", netsvc.LOG_WARNING, 'Warning no ID for submenu %s of menu %s !' % (menu_elem, str(m_l))) pid = self.pool.get('ir.ui.menu').create(cr, self.uid, {'parent_id' : pid, 'name' : menu_elem}) + values['parent_id'] = pid else: - menu_parent_id = self.id_get(cr, 'ir.ui.menu', rec.get('parent','')) + if rec.get('parent'): + menu_parent_id = self.id_get(cr, 'ir.ui.menu', rec.get('parent','')) + else: # we get here with , explicit clear of parent + menu_parent_id = False values = {'parent_id': menu_parent_id} if rec.get('name'): values['name'] = rec.get('name') From fa369ce13c73f32d8763e070322821cfd6a81789 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Mon, 30 Aug 2010 12:49:30 +0300 Subject: [PATCH 2/2] ir_values: Fix logic of group_ids in actions. If an action (eg. wizard) contained groups, those groups would be /forbidden/ to see the action. The correct behaviour is to _allow_ them. bzr revid: p_christ@hol.gr-20100830094930-sv5yfindhg9qx1w3 --- bin/addons/base/ir/ir_values.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py index d7baa6c0f37..8c30a020d0d 100644 --- a/bin/addons/base/ir/ir_values.py +++ b/bin/addons/base/ir/ir_values.py @@ -226,7 +226,7 @@ class ir_values(osv.osv): if groups: cr.execute('SELECT COUNT(1) FROM res_groups_users_rel WHERE gid IN %s AND uid=%s',(tuple(groups), uid)) cnt = cr.fetchone()[0] - if cnt: + if not cnt: res2.remove(r) if r[1] == 'Menuitem' and not res2: raise osv.except_osv('Error !','You do not have the permission to perform this operation !!!')