1051 {'et': etypes[0]}) |
1051 {'et': etypes[0]}) |
1052 if rset: |
1052 if rset: |
1053 return rset.get_entity(0, 0) |
1053 return rset.get_entity(0, 0) |
1054 return self.cmd_add_workflow('%s workflow' % ';'.join(etypes), etypes) |
1054 return self.cmd_add_workflow('%s workflow' % ';'.join(etypes), etypes) |
1055 |
1055 |
1056 @deprecated('[3.5] use add_workflow and Workflow.add_state method') |
1056 @deprecated('[3.5] use add_workflow and Workflow.add_state method', |
|
1057 stacklevel=3) |
1057 def cmd_add_state(self, name, stateof, initial=False, commit=False, **kwargs): |
1058 def cmd_add_state(self, name, stateof, initial=False, commit=False, **kwargs): |
1058 """method to ease workflow definition: add a state for one or more |
1059 """method to ease workflow definition: add a state for one or more |
1059 entity type(s) |
1060 entity type(s) |
1060 """ |
1061 """ |
1061 wf = self._get_or_create_wf(stateof) |
1062 wf = self._get_or_create_wf(stateof) |
1062 state = wf.add_state(name, initial, **kwargs) |
1063 state = wf.add_state(name, initial, **kwargs) |
1063 if commit: |
1064 if commit: |
1064 self.commit() |
1065 self.commit() |
1065 return state.eid |
1066 return state.eid |
1066 |
1067 |
1067 @deprecated('[3.5] use add_workflow and Workflow.add_transition method') |
1068 @deprecated('[3.5] use add_workflow and Workflow.add_transition method', |
|
1069 stacklevel=3) |
1068 def cmd_add_transition(self, name, transitionof, fromstates, tostate, |
1070 def cmd_add_transition(self, name, transitionof, fromstates, tostate, |
1069 requiredgroups=(), conditions=(), commit=False, **kwargs): |
1071 requiredgroups=(), conditions=(), commit=False, **kwargs): |
1070 """method to ease workflow definition: add a transition for one or more |
1072 """method to ease workflow definition: add a transition for one or more |
1071 entity type(s), from one or more state and to a single state |
1073 entity type(s), from one or more state and to a single state |
1072 """ |
1074 """ |
1075 conditions, **kwargs) |
1077 conditions, **kwargs) |
1076 if commit: |
1078 if commit: |
1077 self.commit() |
1079 self.commit() |
1078 return tr.eid |
1080 return tr.eid |
1079 |
1081 |
1080 @deprecated('[3.5] use Transition.set_transition_permissions method') |
1082 @deprecated('[3.5] use Transition.set_transition_permissions method', |
|
1083 stacklevel=3) |
1081 def cmd_set_transition_permissions(self, treid, |
1084 def cmd_set_transition_permissions(self, treid, |
1082 requiredgroups=(), conditions=(), |
1085 requiredgroups=(), conditions=(), |
1083 reset=True, commit=False): |
1086 reset=True, commit=False): |
1084 """set or add (if `reset` is False) groups and conditions for a |
1087 """set or add (if `reset` is False) groups and conditions for a |
1085 transition |
1088 transition |
1087 tr = self._cw.entity_from_eid(treid) |
1090 tr = self._cw.entity_from_eid(treid) |
1088 tr.set_transition_permissions(requiredgroups, conditions, reset) |
1091 tr.set_transition_permissions(requiredgroups, conditions, reset) |
1089 if commit: |
1092 if commit: |
1090 self.commit() |
1093 self.commit() |
1091 |
1094 |
1092 @deprecated('[3.5] use entity.fire_transition("transition") or entity.change_state("state")') |
1095 @deprecated('[3.5] use entity.fire_transition("transition") or entity.change_state("state")', |
|
1096 stacklevel=3) |
1093 def cmd_set_state(self, eid, statename, commit=False): |
1097 def cmd_set_state(self, eid, statename, commit=False): |
1094 self._cw.entity_from_eid(eid).change_state(statename) |
1098 self._cw.entity_from_eid(eid).change_state(statename) |
1095 if commit: |
1099 if commit: |
1096 self.commit() |
1100 self.commit() |
1097 |
1101 |