Inspecting built-in workflows

Odoo includes a built in workflow engine used to manage business document flows and interaction. However, this engine has been gradually replaced by Python business logic and automated actions. As an example of this, one of the most important workflows used to be the one linking sales orders, invoices, and deliveries, but since version 9.0, it has been removed.

But, there are a few workflows still used by some apps, so there may be cases where a developer will need to work with them. So it's still relevant to have some basic understanding of how they work.

The Marketing Campaigns app still uses a simple workflow, and we will use it to provide this brief overview on them.

Getting ready

We will need an Odoo instance with demo data and the Marketing Campaign's addon module installed (not that it's not an app). We also need to have the Developer Mode activated. If it's not, activate it in the Odoo About dialog.

How to do it...

To inspect the workflow defined on a model, follow these steps:

  1. Open the Lead Automation top menu. Depending on the apps you have installed, it could instead be named Marketing. Click on a record on the Campaigns list to open its form view.
    How to do it...
  2. Open the Debug menu (the Bug icon at the right-hand side of the top bar) and choose the Print Workflow option. This will generate a PDF document with a graph of the campaign's workflow, displaying on a red background the workflow node the current document is at.
  3. Again in the Debug menu, select the Edit Workflow option. This will navigate to the Workflow list view filtered by the current workflow. Click on the workflow line in the list to open and inspect its definition.
    How to do it...
  4. Workflows have a Third View mode, the diagram. Clicking on the Third View type icon, at the top right after the form view, we can see the workflow definition in a diagram. The diagram also allows editing: double click on the nodes to edit Activities and on the lines to edit Transitions.
    How to do it...

How it works...

The workflow definitions are stored in the workflow model, and are also reachable through the Settings top menu, and navigate to Technical | Workflows menu item.

Their definition has Activities. The nodes or workflow states, and Transitions, defining when a workflow's current state should move to another node.

Transitions often depend on a workflow Signal to be triggered. A common way to trigger a workflow signal is through form buttons. Buttons support a type="workflow" attribute for this.

Existing workflows are customizable: we can edit or add activities, and we can change the Transitions connecting them. Simple customizations usually involve editing a transition. In the workflow diagram, double clicking a transition arrow brings up its form view. There we rewire the workflow by modifying Destination Activity, adding Condition with a Python expression to evaluate, or using Group Required to limit the transition to be triggered only by users in a certain security group.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.243.100