[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

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

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