Beispiel #1
0
    def update(self):
        cr = self.session.cr

        cr.execute("select * from wkf_workitem where inst_id=%s", (self.instance['id'],))
        for work_item_values in cr.dictfetchall():
            stack = []
            WorkflowItem(self.session, self.record, work_item_values).process(stack=stack)
        return self._update_end()
Beispiel #2
0
    def validate(self, signal, force_running=False):
        assert isinstance(signal, basestring)
        assert isinstance(force_running, bool)

        cr = self.session.cr
        cr.execute("select * from wkf_workitem where inst_id=%s", (self.instance['id'],))
        stack = []
        for work_item_values in cr.dictfetchall():
            wi = WorkflowItem(self.session, self.record, work_item_values)
            wi.process(signal=signal, force_running=force_running, stack=stack)
            # An action is returned
        self._update_end()
        return stack and stack[0] or False
Beispiel #3
0
    def validate(self, signal, force_running=False):
        assert isinstance(signal, str)
        assert isinstance(force_running, bool)

        cr = self.session.cr
        cr.execute("select * from wkf_workitem where inst_id=%s",
                   (self.instance['id'], ))
        stack = []
        for i, work_item_values in enumerate(cr.dictfetchall()):
            if i > 0:
                # test if previous workitem has already processed this one
                cr.execute("select id from wkf_workitem where id=%s",
                           (work_item_values['id'], ))
                if not cr.fetchone():
                    continue
            wi = WorkflowItem(self.session, self.record, work_item_values)
            wi.process(signal=signal, force_running=force_running, stack=stack)
            # An action is returned
        self._update_end()
        return stack and stack[0] or False
Beispiel #4
0
def wi_create(cls, session, record, activity, instance_id, stack):
    assert isinstance(session, Session)
    assert isinstance(record, Record)
    assert isinstance(activity, dict)
    assert isinstance(instance_id, (long, int))
    assert isinstance(stack, list)

    cr = session.cr
    cr.execute(
        "UPDATE wkf_instance SET progress=true, uid=%s, date=now() WHERE activity_id=%s AND res_id = %s and res_type = %s",
        (session.uid, activity['id'], record.id, record.model))
    cr.execute("select nextval('wkf_workitem_id_seq')")
    id_new = cr.fetchone()[0]
    cr.execute(
        "insert into wkf_workitem (id,act_id,inst_id,state) values (%s,%s,%s,'active')",
        (id_new, activity['id'], instance_id))
    cr.execute('select * from wkf_workitem where id=%s', (id_new, ))
    work_item_values = cr.dictfetchone()
    logger.info('Created workflow item in activity %s',
                activity['id'],
                extra={'ident': (session.uid, record.model, record.id)})

    workflow_item = WorkflowItem(session, record, work_item_values)
    workflow_item.process(stack=stack)