3
votes

I have a module that works very well when I use it in Odoo 10. But, in Odoo 11, the part of the workflows doesn't work.

I am new using Odoo 11 and I can't find information about workflows. What are the differences in workflows between Odoo 10 and Odoo 11? I think that I have to change the .xml files.

Thanks in advance.

1
have you thought to simply ask the makers of odoo?Bryan Oakley
@Muhsin k Did my answer solve your question?forvas

1 Answers

13
votes

The workflows are not used in Odoo anymore from version 11 on. They started to be removed in versions 9 and 10 (but they were still available in those versions). They were considered harder to migrate and to deal with because of the lack of flexibility.

So you must remove the workflows you did. Instead of them, you must only use the Python methods called by the buttons, and inside these button methods check the necessary conditions to follow one way or other and call manually other methods which your process must follow. And of course, you must call from there ORM write method to modify the states of the record.

EXAMPLE

With workflows you had something like this:

XML view

<button name="cancel" states="draft,sent" string="Cancel Quotation" groups="base.group_user"/>

XML workflow

<record id="act_draft" model="workflow.activity">
    <field name="wkf_id" ref="wkf_sale"/>
    <field name="flow_start">True</field>
    <field name="name">draft</field>
</record>

<record id="act_cancel" model="workflow.activity">
    <field name="wkf_id" ref="wkf_sale"/>
    <field name="name">cancel</field>
    <field name="flow_stop">True</field>
    <field name="kind">stopall</field>
    <field name="action">action_cancel()</field>
</record>

<record id="trans_draft_cancel" model="workflow.transition">
    <field name="act_from" ref="act_draft"/>
    <field name="act_to" ref="act_cancel"/>
    <field name="signal">cancel</field>
</record>

And now, you should convert that into something like the following:

XML view

<button name="action_cancel" states="draft,sent" string="Cancel Quotation" groups="base.group_user"/>

Python code

@api.multi
def action_cancel(self):
    ...
    self.write({
        'state': 'cancel',
    })