diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py
index f6cffc3944a..03f79a067ce 100644
--- a/bin/addons/base/ir/ir_actions.py
+++ b/bin/addons/base/ir/ir_actions.py
@@ -148,6 +148,26 @@ class act_window(osv.osv):
_table = 'ir_act_window'
_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={}):
res={}
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'),
'auto_refresh': fields.integer('Auto-Refresh',
help='Add an auto-refresh on the view'),
+ 'groups_id': fields.many2many('res.groups', 'ir_act_window_group_rel',
+ 'act_id', 'gid', 'Groups'),
}
_defaults = {
'type': lambda *a: 'ir.actions.act_window',
@@ -261,7 +283,7 @@ def model_get(self, cr, uid, context={}):
wkf_pool = self.pool.get('workflow')
ids = wkf_pool.search(cr, uid, [])
osvs = wkf_pool.read(cr, uid, ids, ['osv'])
-
+
res = []
mpool = self.pool.get('ir.model')
for osv in osvs:
@@ -269,7 +291,7 @@ def model_get(self, cr, uid, context={}):
id = mpool.search(cr, uid, [('model','=',model)])
name = mpool.read(cr, uid, id)[0]['name']
res.append((model, name))
-
+
return res
class ir_model_fields(osv.osv):
@@ -285,26 +307,26 @@ class ir_model_fields(osv.osv):
result = []
mobj = self.pool.get('ir.model')
id = mobj.search(cr, uid, [('model','=',rel)])
-
+
obj = self.pool.get('ir.model.fields')
ids = obj.search(cr, uid, [('model_id','in',id)])
records = obj.read(cr, uid, ids)
for record in records:
id = record['id']
fld = field + '/' + record['name']
-
+
result.append((id, fld))
return result
-
+
if not args:
args=[]
if not context:
context={}
return super(ir_model_fields, self).name_search(cr, uid, name, args, operator, context, limit)
-
+
if context.get('key') != 'server_action':
return super(ir_model_fields, self).name_search(cr, uid, name, args, operator, context, limit)
-
+
result = []
obj = self.pool.get('ir.model.fields')
ids = obj.search(cr, uid, args)
@@ -312,7 +334,7 @@ class ir_model_fields(osv.osv):
for record in records:
id = record['id']
field = record['name']
-
+
if record['ttype'] == 'many2one':
rel = record['relation']
res = get_fields(cr, uid, field, record['relation'])
@@ -320,16 +342,16 @@ class ir_model_fields(osv.osv):
result.append(rs)
result.append((id, field))
-
+
for rs in result:
obj.write(cr, uid, [rs[0]], {'complete_name':rs[1]})
-
+
iids = []
for rs in result:
iids.append(rs[0])
-
+
result = super(ir_model_fields, self).name_search(cr, uid, name, [('complete_name','ilike',name), ('id','in',iids)], operator, context, limit)
-
+
return result
ir_model_fields()
@@ -404,35 +426,35 @@ class actions_server(osv.osv):
""",
'otype': lambda *a: 'copy',
}
-
+
def get_field_value(self, cr, uid, action, context):
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj = obj_pool.browse(cr, uid, id)
-
+
fields = None
-
+
if '/' in action.address.complete_name:
fields = action.address.complete_name.split('/')
elif '.' in action.address.complete_name:
fields = action.address.complete_name.split('.')
-
+
for field in fields:
try:
obj = getattr(obj, field)
except Exception,e :
logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (match.group()))
-
+
return obj
def merge_message(self, cr, uid, keystr, action, context):
logger = netsvc.Logger()
def merge(match):
-
+
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj = obj_pool.browse(cr, uid, id)
-
+
field = match.group()
field = field.replace('[','')
field = field.replace(']','')
@@ -444,13 +466,13 @@ class actions_server(osv.osv):
obj = getattr(obj, field)
except Exception,e :
logger.notifyChannel('Workflow', netsvc.LOG_ERROR, 'Failed to parse : %s' % (match.group()))
-
+
return str(obj)
-
+
com = re.compile('\[\[(.+?)\]\]')
message = com.sub(merge, keystr)
return message
-
+
#
# Context should contains:
# ids : original ids
@@ -473,14 +495,14 @@ class actions_server(osv.osv):
exec action.code in localdict
if 'action' in localdict:
return localdict['action']
-
+
if action.state == 'email':
user = config['email_from']
subject = action.name
-
+
address = self.get_field_value(cr, uid, str(action.message), action, context)
body = self.merge_message(cr, uid, action, context)
-
+
if tools.email_send_attach(user, address, subject, body, debug=False) == True:
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (address))
else:
@@ -492,7 +514,7 @@ class actions_server(osv.osv):
model = res[0]
id = res[1]
wf_service.trg_validate(uid, model, int(id), action.trigger_name, cr)
-
+
if action.state == 'sms':
#TODO: set the user and password from the system
# for the sms gateway user / password
@@ -513,7 +535,7 @@ class actions_server(osv.osv):
'cr': cr,
'uid': uid
}
-
+
for act in action.child_ids:
code = """action = {'model':'%s','type':'%s', %s}""" % (action.model_id.model, act.type, act.usage)
exec code in localdict
@@ -531,7 +553,7 @@ class actions_server(osv.osv):
res[exp.col1.name] = expr
obj_pool = self.pool.get(action.model_id.model)
obj_pool.write(cr, uid, [context.get('active_id')], res)
-
+
if action.state == 'object_create':
res = {}
for exp in action.fields_lines:
@@ -542,7 +564,7 @@ class actions_server(osv.osv):
else:
expr = exp.value
res[exp.col1.name] = expr
-
+
obj_pool = None
if action.state == 'object_create' and action.otype == 'new':
obj_pool = self.pool.get(action.srcmodel_id.model)
@@ -551,7 +573,7 @@ class actions_server(osv.osv):
obj_pool = self.pool.get(action.model_id.model)
id = context.get('active_id')
obj_pool.copy(cr, uid, id, res)
-
+
return False
actions_server()
diff --git a/bin/addons/base/ir/ir_ui_menu.py b/bin/addons/base/ir/ir_ui_menu.py
index 1133c755aa0..a76b8ec1e76 100644
--- a/bin/addons/base/ir/ir_ui_menu.py
+++ b/bin/addons/base/ir/ir_ui_menu.py
@@ -153,7 +153,7 @@ class ir_ui_menu(osv.osv):
'key2': 'tree_but_open',
'res_id': menu_id,
}, context=ctx)
-
+
def _get_icon_pict(self, cr, uid, ids, name, args, context):
res = {}
for m in self.browse(cr, uid, ids, context=context):
diff --git a/bin/addons/base/ir/ir_values.py b/bin/addons/base/ir/ir_values.py
index ee864e2f225..a015071ef93 100644
--- a/bin/addons/base/ir/ir_values.py
+++ b/bin/addons/base/ir/ir_values.py
@@ -144,7 +144,7 @@ class ir_values(osv.osv):
m,res_id = m
else:
res_id=False
-
+
where1 = ['key=%s','model=%s']
where2 = [key,str(m)]
where_opt = []
@@ -172,7 +172,6 @@ class ir_values(osv.osv):
# if not without_user:
where_opt.append('user_id=%d' % (uid,))
-
result = []
ok = True
while ok:
@@ -200,7 +199,7 @@ class ir_values(osv.osv):
'and (company_id is null or company_id = %d) '\
'ORDER BY user_id', (cid,))
result = cr.fetchall()
-
+
def _result_get(x, keys):
if x[1] in keys:
return False
@@ -233,20 +232,20 @@ class ir_values(osv.osv):
res = filter(bool, map(lambda x: _result_get(x, keys), list(result)))
res2 = res[:]
for r in res:
- if type(r) == type([]):
- if r[2]['type'] == 'ir.actions.report.xml' or r[2]['type'] == 'ir.actions.report.xml':
- print
- if r[2].has_key('groups_id'):
- groups = r[2]['groups_id']
- if len(groups) > 0:
- group_ids = ','.join([ str(x) for x in r[2]['groups_id']])
- cr.execute("select count(*) from res_groups_users_rel where gid in (%s) and uid='%s'" % (group_ids, uid))
- gr_ids = cr.fetchall()
- if not gr_ids[0][0] > 0:
- res2.remove(r)
- else:
- #raise osv.except_osv('Error !','You have not permission to perform operation !!!')
- res2.remove(r)
+ if r[2]['type'] in ('ir.actions.report.xml','ir.actions.act_window','ir.actions.wizard'):
+ if r[2].has_key('groups_id'):
+ groups = r[2]['groups_id']
+ if len(groups) > 0:
+ group_ids = ','.join([ str(x) for x in r[2]['groups_id']])
+ cr.execute("select count(*) from res_groups_users_rel where gid in (%s) and uid='%s'" % (group_ids, uid))
+ gr_ids = cr.fetchall()
+ if not gr_ids[0][0] > 0:
+ 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 !!!')
+# else:
+# #raise osv.except_osv('Error !','You have not permission to perform operation !!!')
+# res2.remove(r)
return res2
ir_values()
diff --git a/bin/import_xml.rng b/bin/import_xml.rng
index dd4ca044f80..91b3a9554e5 100644
--- a/bin/import_xml.rng
+++ b/bin/import_xml.rng
@@ -86,6 +86,7 @@
+
@@ -104,6 +105,7 @@
+
@@ -178,6 +180,7 @@
+
diff --git a/bin/netsvc.py b/bin/netsvc.py
index 0e9ead733f7..e67fcea9c58 100644
--- a/bin/netsvc.py
+++ b/bin/netsvc.py
@@ -160,7 +160,7 @@ def init_logger():
logf = config['logfile']
# test if the directories exist, else create them
try:
- handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30)
+ handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30)
except:
sys.stderr.write("ERROR: couldn't create the logfile directory\n")
handler = logging.StreamHandler(sys.stdout)
@@ -185,7 +185,7 @@ def init_logger():
colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', None, 'default']
foreground = lambda f: 30 + colors.index(f)
background = lambda f: 40 + colors.index(f)
-
+
mapping = {
'DEBUG': ('blue', 'default'),
'INFO': ('green', 'default'),
diff --git a/bin/tools/convert.py b/bin/tools/convert.py
index c28bd57fe02..0b073127420 100644
--- a/bin/tools/convert.py
+++ b/bin/tools/convert.py
@@ -230,7 +230,7 @@ class xml_import(object):
assert '.' not in id, """The ID reference "%s" must contains
maximum one dot. They are used to refer to other modules ID, in the
form: module.record_id""" % (xml_id,)
- if module != self.module:
+ if module != self.module:
modcnt = self.pool.get('ir.module.module').search_count(self.cr, self.uid, ['&', ('name', '=', module), ('state', 'in', ['installed'])])
assert modcnt == 1, """The ID "%s" refer to an uninstalled module""" % (xml_id,)
@@ -269,6 +269,20 @@ form: module.record_id""" % (xml_id,)
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
xml_id = rec.getAttribute('id').encode('utf8')
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)
self.idref[xml_id] = int(id)
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'))
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)
self.idref[xml_id] = int(id)
# ir_set
@@ -347,6 +374,7 @@ form: module.record_id""" % (xml_id,)
limit = rec.hasAttribute('limit') and rec.getAttribute('limit').encode('utf-8')
auto_refresh = rec.hasAttribute('auto_refresh') \
and rec.getAttribute('auto_refresh').encode('utf-8')
+# groups_id = rec.hasAttribute('groups') and rec.getAttribute('groups').encode('utf-8')
res = {
'name': name,
@@ -361,7 +389,22 @@ form: module.record_id""" % (xml_id,)
'usage': usage,
'limit': limit,
'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'):
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)
@@ -493,6 +536,7 @@ form: module.record_id""" % (xml_id,)
values['sequence'] = int(rec.getAttribute('sequence'))
if rec.hasAttribute('icon'):
values['icon'] = str(rec.getAttribute('icon'))
+
if rec.hasAttribute('groups'):
g_names = rec.getAttribute('groups').split(',')
groups_value = []