-# -*- encoding: utf-8 -*-
+# -*- coding: utf-8 -*-
##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
-# $Id$
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import netsvc
import osv as base
import pooler
+from tools.safe_eval import safe_eval as eval
class Env(dict):
def __init__(self, cr, uid, model, ids):
ret=False
else:
env = Env(cr, uid, model, ids)
- ret = eval(line, env)
+ ret = eval(line, env, nocopy=True)
return ret
def execute_action(cr, ident, workitem, activity):
return _eval_expr(cr, ident, workitem, activity['action'])
def check(cr, workitem, ident, transition, signal):
- ok = True
- if transition['signal']:
- ok = (signal==transition['signal'])
+ if transition['signal'] and signal != transition['signal']:
+ return False
uid = ident[0]
- if transition['role_id'] and uid != 1:
+ if transition['group_id'] and uid != 1:
pool = pooler.get_pool(cr.dbname)
- user_roles = pool.get('res.users').read(cr, uid, [uid], ['roles_id'])[0]['roles_id']
- ok = ok and pool.get('res.roles').check(cr, uid, user_roles, transition['role_id'])
- ok = ok and _eval_expr(cr, ident, workitem, transition['condition'])
- return ok
+ user_groups = pool.get('res.users').read(cr, uid, [uid], ['groups_id'])[0]['groups_id']
+ if not transition['group_id'] in user_groups:
+ return False
+
+ return _eval_expr(cr, ident, workitem, transition['condition'])
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: