This question has been flagged
2 Replies
5530 Views

Hi,

in the Odoo docs it says:

Workflow transitions can be restricted to a specific group. Users outside the group can not trigger the transition.

How can I achieve this in the xml definition of the transition?

This is my transition definition:

<record model="workflow.transition" id="paper_reviewed_to_accepted">
<field name="act_from" ref="paper_reviewed"/>
<field name="act_to" ref="paper_accepted"/>
<field name="signal">accepted</field>
</record>


SOLUTION:

make the transition only available to a group:

<record model="workflow.transition" id="paper_reviewed_to_accepted">    
    <field name="act_from" ref="paper_reviewed"/>
    <field name="act_to" ref="paper_accepted"/>
    <field name="group_id" ref="module.xml_id_of_the_group"/>
    <field name="signal">accepted</field>
</record>

If you have a button to trigger the transition it is still visible to everybody. To only make it visible to the group, for which the transition is available, do:

<button name="in_review" type="workflow" string="Set to In Review"
    states="submitted" class="oe_highlight"
    groups="module.xml_id_of_the_group"

/>


Avatar
Discard
Best Answer

Hi, it is as simple as adding the following tag:


<field name="group_id" ref="module.xml_id_of_the_group"/> 


Leaving your transition as:

<record model="workflow.transition" id="paper_reviewed_to_accepted"> 
<field name="act_from" ref="paper_reviewed"/>
<field name="act_to" ref="paper_accepted"/>
<field name="group_id" ref="module.xml_id_of_the_group"/>
<field name="signal">accepted</field>
</record>

 Hope it helps!

Avatar
Discard
Best Answer

You must proceed with what Lucio has explained. That answer is pretty right.

In an additional logic, you can set the groups on button which triggers the signal.

Example : <button name="invoice_open" states="draft,proforma2" string="Validate" class="oe_highlight" groups="account.group_account_invoice"/>

Thanks.

Avatar
Discard