[MERGE] fix: ir_values action permissions + issue with menus during updates
ir_values: fix logic of group_ids in actions after bad refactoring convert: When loading menu, don't match by name bzr revid: odo@openerp.com-20100830100546-5wtg3cxhw3qy2adg
This commit is contained in:
@@ -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 !!!')
|
||||
|
||||
+10
-10
@@ -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 <menuitem parent="">, explicit clear of parent
|
||||
menu_parent_id = False
|
||||
values = {'parent_id': menu_parent_id}
|
||||
if rec.get('name'):
|
||||
values['name'] = rec.get('name')
|
||||
|
||||
Reference in New Issue
Block a user