[REM] all: modules: removed all remaining references to res.roles, replaced by specif...
[odoo/odoo.git] / addons / process / process.py
index 5f02b67..479b874 100644 (file)
@@ -1,47 +1,45 @@
-# -*- 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-2010 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
+#    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 pooler, tools
-
+import pooler
+import tools
 from osv import fields, osv
 
 class Env(dict):
-    
+
     def __init__(self, obj, user):
         self.__obj = obj
         self.__usr = user
-        
+
     def __getitem__(self, name):
-        
+
         if name in ('__obj', '__user'):
             return super(ExprContext, self).__getitem__(name)
-        
+
         if name == 'user':
             return self.__user
-        
+
         if name == 'object':
             return self.__obj
-        
+
         return self.__obj[name]
 
 class process_process(osv.osv):
@@ -49,7 +47,7 @@ class process_process(osv.osv):
     _description = "Process"
     _columns = {
         'name': fields.char('Name', size=30,required=True, translate=True),
-        'active': fields.boolean('Active'),
+        'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the process without removing it."),
         'model_id': fields.many2one('ir.model', 'Object', ondelete='set null'),
         'note': fields.text('Notes', translate=True),
         'node_ids': fields.one2many('process.node', 'process_id', 'Nodes')
@@ -86,7 +84,7 @@ class process_process(osv.osv):
     def graph_get(self, cr, uid, id, res_model, res_id, scale, context):
 
         pool = pooler.get_pool(cr.dbname)
-        
+
         process = pool.get('process.process').browse(cr, uid, [id], context)[0]
 
         name = process.name
@@ -132,14 +130,15 @@ class process_process(osv.osv):
 
             if 'directory_id' in node and node.directory_id:
                 data['directory_id'] = node.directory_id.id
+                data['directory'] = self.pool.get('document.directory').get_resource_path(cr, uid, data['directory_id'], data['model'], False)
 
             if node.menu_id:
                 data['menu'] = {'name': node.menu_id.complete_name, 'id': node.menu_id.id}
-            
+
             if node.model_id and node.model_id.model == res_model:
                 try:
                     data['active'] = eval(node.model_states, expr_context)
-                except Exception, e:
+                except Exception:
                     pass
 
             if not data['active']:
@@ -169,23 +168,19 @@ class process_process(osv.osv):
                     button['state'] = b.state
                     button['action'] = b.action
                     buttons.append(button)
-                data['roles'] = roles = []
+                data['groups'] = groups = []
                 for r in tr.transition_ids:
-                    if r.role_id:
-                        role = {}
-                        role['name'] = r.role_id.name
-                        roles.append(role)
-                for r in tr.role_ids:
-                    role = {}
-                    role['name'] = r.name
-                    roles.append(role)
+                    if r.group_id:
+                        groups.append({'name': r.group_id.name})
+                for r in tr.group_ids:
+                    groups.append({'name': r.name})
                 transitions[tr.id] = data
 
         # now populate resource information
         def update_relatives(nid, ref_id, ref_model):
             relatives = []
 
-            for tid, tr in transitions.items():
+            for dummy, tr in transitions.items():
                 if tr['source'] == nid:
                     relatives.append(tr['target'])
                 if tr['target'] == nid:
@@ -200,7 +195,7 @@ class process_process(osv.osv):
             refobj = pool.get(ref_model).browse(cr, uid, [ref_id], context)[0]
             fields = pool.get(ref_model).fields_get(cr, uid, context=context)
 
-            # chech for directory_id from inherited from document module
+            # check for directory_id from inherited from document module
             if nodes[nid].get('directory_id', False):
                 resource['directory'] = self.pool.get('document.directory').get_resource_path(cr, uid, nodes[nid]['directory_id'], ref_model, ref_id)
 
@@ -233,7 +228,7 @@ class process_process(osv.osv):
 
         # calculate graph layout
         g = tools.graph(nodes.keys(), map(lambda x: (x['source'], x['target']), transitions.values()))
-        g.process(start)        
+        g.process(start)
         g.scale(*scale) #g.scale(100, 100, 180, 120)
         graph = g.result_get()
 
@@ -296,7 +291,7 @@ process_process()
 
 class process_node(osv.osv):
     _name = 'process.node'
-    _description ='Process Nodes'
+    _description ='Process Node'
     _columns = {
         'name': fields.char('Name', size=30,required=True, translate=True),
         'process_id': fields.many2one('process.process', 'Process', required=True, ondelete='cascade'),
@@ -318,14 +313,14 @@ class process_node(osv.osv):
         'flow_start': lambda *args: False,
     }
 
-    def copy(self, cr, uid, id, default=None, context={}):
+    def copy_data(self, cr, uid, id, default=None, context={}):
         if not default:
             default = {}
         default.update({
             'transition_in': [],
             'transition_out': []
         })
-        return super(process_node, self).copy(cr, uid, id, default, context)
+        return super(process_node, self).copy_data(cr, uid, id, default, context)
 
 process_node()
 
@@ -342,14 +337,14 @@ process_node_condition()
 
 class process_transition(osv.osv):
     _name = 'process.transition'
-    _description ='Process Transitions'
+    _description ='Process Transition'
     _columns = {
         'name': fields.char('Name', size=32, required=True, translate=True),
         'source_node_id': fields.many2one('process.node', 'Source Node', required=True, ondelete='cascade'),
         'target_node_id': fields.many2one('process.node', 'Target Node', required=True, ondelete='cascade'),
         'action_ids': fields.one2many('process.transition.action', 'transition_id', 'Buttons'),
         'transition_ids': fields.many2many('workflow.transition', 'process_transition_ids', 'ptr_id', 'wtr_id', 'Workflow Transitions'),
-        'role_ids': fields.many2many('res.roles', 'process_transition_roles_rel', 'tid', 'rid', 'Roles'),
+        'group_ids': fields.many2many('res.groups', 'process_transition_group_rel', 'tid', 'rid', string='Required Groups'),
         'note': fields.text('Description', translate=True),
     }
 process_transition()
@@ -375,7 +370,7 @@ class process_transition_action(osv.osv):
         'state': lambda *args: 'dummy',
     }
 
-    def copy(self, cr, uid, id, default=None, context={}):
+    def copy_data(self, cr, uid, id, default=None, context={}):
         if not default:
             default = {}
 
@@ -383,7 +378,8 @@ class process_transition_action(osv.osv):
         if state:
             default['state'] = state
 
-        return super(process_transition_action, self).copy(cr, uid, id, default, context)
+        return super(process_transition_action, self).copy_data(cr, uid, id, default, context)
 
 process_transition_action()
 
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: