~syleam/openobject-server/trunk-acl-per-company

« back to all changes in this revision

Viewing changes to bin/addons/base/ir/workflow/workflow.py

  • Committer: Mantavya Gajjar
  • Date: 2010-03-17 13:23:29 UTC
  • mfrom: (2111.1.16 openerp-server)
  • Revision ID: mga@mga-20100317132329-kma6kea8k1clpuco
[MERGE]: merging from the server development team branch
location : lp:~openerp-dev/openobject-server/trunk-dev-framework

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        wf_service.clear_cache(cr, user)
45
45
        return super(workflow, self).write(cr, user, ids, vals, context=context)
46
46
 
 
47
    def get_active_workitems(self, cr, uid, res, res_id, context={}):
 
48
        
 
49
        cr.execute('select * from wkf where osv=%s limit 1',(res,))
 
50
        wkfinfo = cr.dictfetchone()
 
51
        workitems = []
 
52
        
 
53
        if wkfinfo:
 
54
            cr.execute('SELECT id FROM wkf_instance \
 
55
                            WHERE res_id=%s AND wkf_id=%s \
 
56
                            ORDER BY state LIMIT 1',
 
57
                            (res_id, wkfinfo['id']))
 
58
            inst_id = cr.fetchone()
 
59
         
 
60
            cr.execute('select act_id,count(*) from wkf_workitem where inst_id=%s group by act_id', (inst_id,))
 
61
            workitems = dict(cr.fetchall())        
 
62
         
 
63
        return {'wkf': wkfinfo, 'workitems':  workitems}
 
64
 
 
65
 
47
66
    #
48
67
    # scale =  (vertical-distance, horizontal-distance, min-node-width(optional), min-node-height(optional), margin(default=20))
49
68
    #
50
69
 
51
70
 
52
 
    def graph_get(self, cr, uid, id, scale, context={}):
53
 
 
54
 
        nodes= []
55
 
        nodes_name = []
56
 
        transitions = []
57
 
        start = []
58
 
        tres = {}
59
 
        no_ancester = []
60
 
        workflow = self.browse(cr, uid, id, context)
61
 
        for a in workflow.activities:
62
 
            nodes_name.append((a.id,a.name))
63
 
            nodes.append(a.id)
64
 
            if a.flow_start:
65
 
                start.append(a.id)
66
 
            else:
67
 
                if not a.in_transitions:
68
 
                    no_ancester.append(a.id)
69
 
 
70
 
            for t in a.out_transitions:
71
 
                transitions.append((a.id, t.act_to.id))
72
 
                tres[t.id] = (a.id, t.act_to.id)
73
 
 
74
 
 
75
 
        g  = graph(nodes, transitions, no_ancester)
76
 
        g.process(start)
77
 
        g.scale(*scale)
78
 
        result = g.result_get()
79
 
        results = {}
80
 
 
81
 
        for node in nodes_name:
82
 
            results[str(node[0])] = result[node[0]]
83
 
            results[str(node[0])]['name'] = node[1]
84
 
 
85
 
        return {'nodes': results, 'transitions': tres}
 
71
#    def graph_get(self, cr, uid, id, scale, context={}):
 
72
#
 
73
#        nodes= []
 
74
#        nodes_name = []
 
75
#        transitions = []
 
76
#        start = []
 
77
#        tres = {}
 
78
#        no_ancester = []
 
79
#        workflow = self.browse(cr, uid, id, context)
 
80
#        for a in workflow.activities:
 
81
#            nodes_name.append((a.id,a.name))
 
82
#            nodes.append(a.id)
 
83
#            if a.flow_start:
 
84
#                start.append(a.id)
 
85
#            else:
 
86
#                if not a.in_transitions:
 
87
#                    no_ancester.append(a.id)
 
88
#
 
89
#            for t in a.out_transitions:
 
90
#                transitions.append((a.id, t.act_to.id))
 
91
#                tres[t.id] = (a.id, t.act_to.id)
 
92
#
 
93
#
 
94
#        g  = graph(nodes, transitions, no_ancester)
 
95
#        g.process(start)
 
96
#        g.scale(*scale)
 
97
#        result = g.result_get()
 
98
#        results = {}
 
99
#
 
100
#        for node in nodes_name:
 
101
#            results[str(node[0])] = result[node[0]]
 
102
#            results[str(node[0])]['name'] = node[1]
 
103
#
 
104
#        return {'nodes': results, 'transitions': tres}
86
105
 
87
106
 
88
107
    def create(self, cr, user, vals, context=None):