How to implement transitions in workflows with states and substates?

Trying substate transitions work in workflows

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.


  • 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.


  • 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.


  • 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() ?
  • Is there a better method to achieve our purpose?
  • An example code is also welcome.

We appreciate your guidance.

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.

Thank you @ced

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).

At first I thought about having independent transitions, but now that you bring the subject we could try to include conditional transition based on other fields than the workflow state.
But this is for the one who will develop Issue 9952: Permit multiple workflow - Tryton issue tracker or if needed it should be discussed in a topic of

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.