To have substates, we want to implement transitions by clicking on buttons, and we expect the transition of the substate to behave as Workflow.transition() does with states.
Behavior:
In a model we implement the fields “state” and “sub_state” defined as “fields.Selection” fields.
We create buttons for each of the options in each “state” and “sub_state” field.
Whit workflow.transition() in buttons, changes the state of the “state” field, but the “sub_state” field does not change the state.
Difficulty:
Making the “sub_state” field behave the same as “state”.
According to the rule of model.workflow.transition, a default field called “state” is required, which we already see functional.
Environment:
OS: Ubuntu 20.04.1 LTS
Python: 3.8.5
Trytond: 5.8.1
Tryton: 5.8.1
Module: 5.8
Postgresql: 12.5
The expected:
How to correctly implement the transition of the sub-state within each state? we are doing well by using model.workflow.transition() ?
The Workflow mixin does not support multiple state field.
But I think it should be possible to modify it to convert it into a generator of mixin where the _transition_state and _transitions attributes would have a configurable name. I think such development will be welcomed in standard as long as it does not alter the behavior of the current Workflow class (indeed it should just generate one).
With better knowledge it will be interesting to contribute with your recommendation, for now, let’s recognize how Tryton works. Substates are not essential to our immediate purpose, so we will look for alternatives.
How would a subworkflow work with relation to the parent workflow?
Would it be something totally independent (that’s what I understand from your message) or would the transition in the parent workflow be only possible in some specific states of the subworkflow (it makes the whole subject way more difficult).