Added Groups option for report,wizard and act_window.
bzr revid: jvo@tinyerp.com-20080918140205-dod9qocp1n1u9q0b
This commit is contained in:
parent
deec1863f6
commit
34fcda731a
|
@ -148,6 +148,26 @@ class act_window(osv.osv):
|
||||||
_table = 'ir_act_window'
|
_table = 'ir_act_window'
|
||||||
_sequence = 'ir_actions_id_seq'
|
_sequence = 'ir_actions_id_seq'
|
||||||
|
|
||||||
|
# def search(self, cr, uid, args, offset=0, limit=2000, order=None,
|
||||||
|
# context=None, count=False):
|
||||||
|
# if context is None:
|
||||||
|
# context = {}
|
||||||
|
# ids = osv.orm.orm.search(self, cr, uid, args, offset, limit, order,
|
||||||
|
# context=context)
|
||||||
|
# if uid==1:
|
||||||
|
# return ids
|
||||||
|
# user_groups = self.pool.get('res.users').read(cr, uid, [uid])[0]['groups_id']
|
||||||
|
# result = []
|
||||||
|
# for act in self.browse(cr, uid, ids):
|
||||||
|
# if not len(act.groups_id):
|
||||||
|
# result.append(act.id)
|
||||||
|
# continue
|
||||||
|
# for g in act.groups_id:
|
||||||
|
# if g.id in user_groups:
|
||||||
|
# result.append(act.id)
|
||||||
|
# break
|
||||||
|
# return result
|
||||||
|
|
||||||
def _views_get_fnc(self, cr, uid, ids, name, arg, context={}):
|
def _views_get_fnc(self, cr, uid, ids, name, arg, context={}):
|
||||||
res={}
|
res={}
|
||||||
for act in self.browse(cr, uid, ids):
|
for act in self.browse(cr, uid, ids):
|
||||||
|
@ -186,6 +206,8 @@ class act_window(osv.osv):
|
||||||
'limit': fields.integer('Limit', help='Default limit for the list view'),
|
'limit': fields.integer('Limit', help='Default limit for the list view'),
|
||||||
'auto_refresh': fields.integer('Auto-Refresh',
|
'auto_refresh': fields.integer('Auto-Refresh',
|
||||||
help='Add an auto-refresh on the view'),
|
help='Add an auto-refresh on the view'),
|
||||||
|
'groups_id': fields.many2many('res.groups', 'ir_act_window_group_rel',
|
||||||
|
'act_id', 'gid', 'Groups'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'type': lambda *a: 'ir.actions.act_window',
|
'type': lambda *a: 'ir.actions.act_window',
|
||||||
|
|
|
@ -172,7 +172,6 @@ class ir_values(osv.osv):
|
||||||
# if not without_user:
|
# if not without_user:
|
||||||
where_opt.append('user_id=%d' % (uid,))
|
where_opt.append('user_id=%d' % (uid,))
|
||||||
|
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
ok = True
|
ok = True
|
||||||
while ok:
|
while ok:
|
||||||
|
@ -233,9 +232,7 @@ class ir_values(osv.osv):
|
||||||
res = filter(bool, map(lambda x: _result_get(x, keys), list(result)))
|
res = filter(bool, map(lambda x: _result_get(x, keys), list(result)))
|
||||||
res2 = res[:]
|
res2 = res[:]
|
||||||
for r in res:
|
for r in res:
|
||||||
if type(r) == type([]):
|
if r[2]['type'] in ('ir.actions.report.xml','ir.actions.act_window','ir.actions.wizard'):
|
||||||
if r[2]['type'] == 'ir.actions.report.xml' or r[2]['type'] == 'ir.actions.report.xml':
|
|
||||||
print
|
|
||||||
if r[2].has_key('groups_id'):
|
if r[2].has_key('groups_id'):
|
||||||
groups = r[2]['groups_id']
|
groups = r[2]['groups_id']
|
||||||
if len(groups) > 0:
|
if len(groups) > 0:
|
||||||
|
@ -244,9 +241,11 @@ class ir_values(osv.osv):
|
||||||
gr_ids = cr.fetchall()
|
gr_ids = cr.fetchall()
|
||||||
if not gr_ids[0][0] > 0:
|
if not gr_ids[0][0] > 0:
|
||||||
res2.remove(r)
|
res2.remove(r)
|
||||||
else:
|
if r[1]=='Menuitem' and not res2:
|
||||||
#raise osv.except_osv('Error !','You have not permission to perform operation !!!')
|
raise osv.except_osv('Error !','You do not have the permission to perform this operation !!!')
|
||||||
res2.remove(r)
|
# else:
|
||||||
|
# #raise osv.except_osv('Error !','You have not permission to perform operation !!!')
|
||||||
|
# res2.remove(r)
|
||||||
return res2
|
return res2
|
||||||
ir_values()
|
ir_values()
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
<rng:optional><rng:attribute name="keyword" /></rng:optional>
|
<rng:optional><rng:attribute name="keyword" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="multi" /></rng:optional>
|
<rng:optional><rng:attribute name="multi" /></rng:optional>
|
||||||
<rng:optional><rng:attribute name="client_action_multi" /></rng:optional>
|
<rng:optional><rng:attribute name="client_action_multi" /></rng:optional>
|
||||||
|
<rng:optional> <rng:attribute name="groups"/> </rng:optional>
|
||||||
</rng:element>
|
</rng:element>
|
||||||
</rng:define>
|
</rng:define>
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@
|
||||||
<rng:optional> <rng:attribute name="auto" /> </rng:optional>
|
<rng:optional> <rng:attribute name="auto" /> </rng:optional>
|
||||||
<rng:optional> <rng:attribute name="header" /> </rng:optional>
|
<rng:optional> <rng:attribute name="header" /> </rng:optional>
|
||||||
<rng:optional> <rng:attribute name="attachment" /> </rng:optional>
|
<rng:optional> <rng:attribute name="attachment" /> </rng:optional>
|
||||||
|
<rng:optional> <rng:attribute name="groups"/> </rng:optional>
|
||||||
<rng:empty />
|
<rng:empty />
|
||||||
</rng:element>
|
</rng:element>
|
||||||
</rng:define>
|
</rng:define>
|
||||||
|
@ -178,6 +180,7 @@
|
||||||
<rng:optional> <rng:attribute name="view_mode"/> </rng:optional>
|
<rng:optional> <rng:attribute name="view_mode"/> </rng:optional>
|
||||||
<rng:optional> <rng:attribute name="multi"/> </rng:optional>
|
<rng:optional> <rng:attribute name="multi"/> </rng:optional>
|
||||||
<rng:optional> <rng:attribute name="target"/> </rng:optional>
|
<rng:optional> <rng:attribute name="target"/> </rng:optional>
|
||||||
|
<rng:optional> <rng:attribute name="groups"/> </rng:optional>
|
||||||
<rng:empty />
|
<rng:empty />
|
||||||
</rng:element>
|
</rng:element>
|
||||||
</rng:define>
|
</rng:define>
|
||||||
|
|
|
@ -269,6 +269,20 @@ form: module.record_id""" % (xml_id,)
|
||||||
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
||||||
xml_id = rec.getAttribute('id').encode('utf8')
|
xml_id = rec.getAttribute('id').encode('utf8')
|
||||||
self._test_xml_id(xml_id)
|
self._test_xml_id(xml_id)
|
||||||
|
|
||||||
|
if rec.hasAttribute('groups'):
|
||||||
|
g_names = rec.getAttribute('groups').split(',')
|
||||||
|
groups_value = []
|
||||||
|
groups_obj = self.pool.get('res.groups')
|
||||||
|
for group in g_names:
|
||||||
|
if group.startswith('-'):
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group[1:])
|
||||||
|
groups_value.append((3, group_id))
|
||||||
|
else:
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group)
|
||||||
|
groups_value.append((4, group_id))
|
||||||
|
res['groups_id'] = groups_value
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode)
|
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] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
|
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
|
||||||
|
@ -296,6 +310,19 @@ form: module.record_id""" % (xml_id,)
|
||||||
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
||||||
res = {'name': string, 'wiz_name': name, 'multi':multi}
|
res = {'name': string, 'wiz_name': name, 'multi':multi}
|
||||||
|
|
||||||
|
if rec.hasAttribute('groups'):
|
||||||
|
g_names = rec.getAttribute('groups').split(',')
|
||||||
|
groups_value = []
|
||||||
|
groups_obj = self.pool.get('res.groups')
|
||||||
|
for group in g_names:
|
||||||
|
if group.startswith('-'):
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group[1:])
|
||||||
|
groups_value.append((3, group_id))
|
||||||
|
else:
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group)
|
||||||
|
groups_value.append((4, group_id))
|
||||||
|
res['groups_id'] = groups_value
|
||||||
|
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, mode=self.mode)
|
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, mode=self.mode)
|
||||||
self.idref[xml_id] = int(id)
|
self.idref[xml_id] = int(id)
|
||||||
# ir_set
|
# ir_set
|
||||||
|
@ -347,6 +374,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
limit = rec.hasAttribute('limit') and rec.getAttribute('limit').encode('utf-8')
|
limit = rec.hasAttribute('limit') and rec.getAttribute('limit').encode('utf-8')
|
||||||
auto_refresh = rec.hasAttribute('auto_refresh') \
|
auto_refresh = rec.hasAttribute('auto_refresh') \
|
||||||
and rec.getAttribute('auto_refresh').encode('utf-8')
|
and rec.getAttribute('auto_refresh').encode('utf-8')
|
||||||
|
# groups_id = rec.hasAttribute('groups') and rec.getAttribute('groups').encode('utf-8')
|
||||||
|
|
||||||
res = {
|
res = {
|
||||||
'name': name,
|
'name': name,
|
||||||
|
@ -361,7 +389,22 @@ form: module.record_id""" % (xml_id,)
|
||||||
'usage': usage,
|
'usage': usage,
|
||||||
'limit': limit,
|
'limit': limit,
|
||||||
'auto_refresh': auto_refresh,
|
'auto_refresh': auto_refresh,
|
||||||
|
# 'groups_id':groups_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rec.hasAttribute('groups'):
|
||||||
|
g_names = rec.getAttribute('groups').split(',')
|
||||||
|
groups_value = []
|
||||||
|
groups_obj = self.pool.get('res.groups')
|
||||||
|
for group in g_names:
|
||||||
|
if group.startswith('-'):
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group[1:])
|
||||||
|
groups_value.append((3, group_id))
|
||||||
|
else:
|
||||||
|
group_id = self.id_get(cr, 'res.groups', group)
|
||||||
|
groups_value.append((4, group_id))
|
||||||
|
res['groups_id'] = groups_value
|
||||||
|
|
||||||
if rec.hasAttribute('target'):
|
if rec.hasAttribute('target'):
|
||||||
res['target'] = rec.getAttribute('target')
|
res['target'] = rec.getAttribute('target')
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, mode=self.mode)
|
id = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, mode=self.mode)
|
||||||
|
@ -493,6 +536,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
values['sequence'] = int(rec.getAttribute('sequence'))
|
values['sequence'] = int(rec.getAttribute('sequence'))
|
||||||
if rec.hasAttribute('icon'):
|
if rec.hasAttribute('icon'):
|
||||||
values['icon'] = str(rec.getAttribute('icon'))
|
values['icon'] = str(rec.getAttribute('icon'))
|
||||||
|
|
||||||
if rec.hasAttribute('groups'):
|
if rec.hasAttribute('groups'):
|
||||||
g_names = rec.getAttribute('groups').split(',')
|
g_names = rec.getAttribute('groups').split(',')
|
||||||
groups_value = []
|
groups_value = []
|
||||||
|
|
Loading…
Reference in New Issue