From 76201eb88a69fa27c9f1d300f03984971bbf830c Mon Sep 17 00:00:00 2001
From: "nch@tinyerp.com" <>
Date: Wed, 28 Apr 2010 12:24:06 +0530
Subject: [PATCH] [IMP]:ir.actions.todo added groups to the actions
bzr revid: nch@tinyerp.com-20100428065406-97056qrpvp4tun0e
---
bin/addons/base/ir/ir.xml | 5 +++++
bin/addons/base/ir/ir_actions.py | 13 +++++++------
bin/addons/base/res/res_config.py | 12 +++++++++++-
3 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/bin/addons/base/ir/ir.xml b/bin/addons/base/ir/ir.xml
index 667a77e8a13..77ae7643645 100644
--- a/bin/addons/base/ir/ir.xml
+++ b/bin/addons/base/ir/ir.xml
@@ -1383,6 +1383,11 @@
+
+
+
+
+
diff --git a/bin/addons/base/ir/ir_actions.py b/bin/addons/base/ir/ir_actions.py
index 33be3fe99ee..a9eab3ea3da 100644
--- a/bin/addons/base/ir/ir_actions.py
+++ b/bin/addons/base/ir/ir_actions.py
@@ -387,13 +387,13 @@ class actions_server(osv.osv):
line = rs[0], "%s - (%s)" % (rs[1], rs[0])
res.append(line)
return res
-
+
def _select_objects(self, cr, uid, context={}):
model_pool = self.pool.get('ir.model')
ids = model_pool.search(cr, uid, [('name','not ilike','.')])
res = model_pool.read(cr, uid, ids, ['model', 'name'])
return [(r['model'], r['name']) for r in res] + [('','')]
-
+
def change_object(self, cr, uid, ids, copy_object, state, context={}):
if state == 'object_copy':
model_pool = self.pool.get('ir.model')
@@ -581,10 +581,10 @@ class actions_server(osv.osv):
continue
if not user:
raise osv.except_osv(_('Error'), _("Please specify server option --smtp-from !"))
-
+
subject = self.merge_message(cr, uid, action.subject, action, context)
body = self.merge_message(cr, uid, action.message, action, context)
-
+
if tools.email_send(user, [address], subject, body, debug=False, subtype='html') == True:
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (address))
else:
@@ -686,7 +686,7 @@ class actions_server(osv.osv):
cr.commit()
if action.record_id:
self.pool.get(action.model_id.model).write(cr, uid, [context.get('active_id')], {action.record_id.name:res_id})
-
+
if action.state == 'object_copy':
res = {}
for exp in action.fields_lines:
@@ -701,7 +701,7 @@ class actions_server(osv.osv):
obj_pool = None
res_id = False
-
+
model = action.copy_object.split(',')[0]
cid = action.copy_object.split(',')[1]
obj_pool = self.pool.get(model)
@@ -736,6 +736,7 @@ class ir_actions_todo(osv.osv):
'state': fields.selection(TODO_STATES, string='State', required=True),
'name':fields.char('Name', size=64),
'restart': fields.selection([('onskip','On Skip'),('always','Always'),('never','Never')],'Restart',required=True),
+ 'groups_id':fields.many2many('res.groups', 'res_groups_action_rel', 'uid', 'gid', 'Groups'),
'note':fields.text('Text', translate=True),
}
_defaults={
diff --git a/bin/addons/base/res/res_config.py b/bin/addons/base/res/res_config.py
index 68a5a383cbb..9899830a4f3 100644
--- a/bin/addons/base/res/res_config.py
+++ b/bin/addons/base/res/res_config.py
@@ -58,8 +58,18 @@ class res_config_configurable(osv.osv_memory):
'getting next %s' % todos)
active_todos = todos.search(cr, uid, [('state','=','open')],
limit=1)
+ dont_skip_todo = True
if active_todos:
- return todos.browse(cr, uid, active_todos[0], context=None)
+ todo_obj = todos.browse(cr, uid, active_todos[0], context=None)
+ todo_groups = map(lambda x:x.id, todo_obj.groups_id)
+ if todo_groups:
+ cr.execute("select 1 from res_groups_users_rel where uid=%s and gid=ANY(%s)",(uid, todo_groups,))
+ dont_skip_todo = bool(cr.fetchone())
+ if dont_skip_todo:
+ return todos.browse(cr, uid, active_todos[0], context=None)
+ else:
+ todos.write(cr, uid, active_todos[0], {'state':'skip'}, context=None)
+ return self._next_action(cr, uid)
return None
def _set_previous_todo(self, cr, uid, state):