hooks/workflow.py
branchstable
changeset 4644 021035b9a7ab
parent 4307 7fba9c34c88f
child 4719 aaed3f813ef8
equal deleted inserted replaced
4643:921737d2e3a8 4644:021035b9a7ab
   230                 if not tr.may_be_fired(foreid):
   230                 if not tr.may_be_fired(foreid):
   231                     msg = session._("transition may not be fired")
   231                     msg = session._("transition may not be fired")
   232                     raise ValidationError(entity.eid, {'by_transition': msg})
   232                     raise ValidationError(entity.eid, {'by_transition': msg})
   233             if entity.get('to_state'):
   233             if entity.get('to_state'):
   234                 deststateeid = entity['to_state']
   234                 deststateeid = entity['to_state']
   235                 if not cowpowers and deststateeid != tr.destination().eid:
   235                 if not cowpowers and deststateeid != tr.destination(forentity).eid:
   236                     msg = session._("transition isn't allowed")
   236                     msg = session._("transition isn't allowed")
   237                     raise ValidationError(entity.eid, {'by_transition': msg})
   237                     raise ValidationError(entity.eid, {'by_transition': msg})
   238                 if swtr is None:
   238                 if swtr is None:
   239                     deststate = session.entity_from_eid(deststateeid)
   239                     deststate = session.entity_from_eid(deststateeid)
   240                     if not cowpowers and deststate is None:
   240                     if not cowpowers and deststate is None:
   241                         msg = session._("state doesn't belong to entity's workflow")
   241                         msg = session._("state doesn't belong to entity's workflow")
   242                         raise ValidationError(entity.eid, {'to_state': msg})
   242                         raise ValidationError(entity.eid, {'to_state': msg})
   243             else:
   243             else:
   244                 deststateeid = tr.destination().eid
   244                 deststateeid = tr.destination(forentity).eid
   245         # everything is ok, add missing information on the trinfo entity
   245         # everything is ok, add missing information on the trinfo entity
   246         entity['from_state'] = fromstate.eid
   246         entity['from_state'] = fromstate.eid
   247         entity['to_state'] = deststateeid
   247         entity['to_state'] = deststateeid
   248         nocheck = session.transaction_data.setdefault('skip-security', set())
   248         nocheck = session.transaction_data.setdefault('skip-security', set())
   249         nocheck.add((entity.eid, 'from_state', fromstate.eid))
   249         nocheck.add((entity.eid, 'from_state', fromstate.eid))