[IMP]:ir.actions.todo added groups to the actions

bzr revid: nch@tinyerp.com-20100428065406-97056qrpvp4tun0e
This commit is contained in:
nch@tinyerp.com 2010-04-28 12:24:06 +05:30
parent 1e186b3c12
commit 76201eb88a
3 changed files with 23 additions and 7 deletions

View File

@ -1383,6 +1383,11 @@
<field name="action_id" select="1"/>
<field name="restart"/>
<field name="state"/>
<notebook colspan="4">
<page string="Groups">
<field name="groups_id" nolabel="1" colspan="4"/>
</page>
</notebook>
</form>
</field>
</record>

View File

@ -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={

View File

@ -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):