workflow 'group required' field not working

Asked by Colin MacMillan

As an example, the Purchase Order workflow ...

The Draft state has two outgoing transitions - Confirmed (purchase_confirm) and Cancel (purchase_cancel).

If I create a 'Group Required' entry for the confirmed transition. Nothing happens. If my user does not have that group assigned, I *should* be prevented from moving along the next stage of the workflow.

I checked the code (but I'm not a programmer) and it does not look like the Group Required field is evaluated. Check - wkf_confirm_order()

I might be missing something but it does not seem that this functionality has been implemented.

I also checked Sales Orders with the same result.

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Addons (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Olivier Dony (Odoo)
Solved:
Last query:
Last reply:

This question was originally filed as bug #706886.

Revision history for this message
Colin MacMillan (colin-macmillan) said :
#1

openobject-addons - revno 4359

Revision history for this message
Amit Parik (amit-parik) said :
#2

Hello Colin MacMillan,

If you are giving the rights on your particular user then you have to set group on the work-flow buttons.
And then assign this groups to your user.

Now you can see those buttons for only this user.

By doing this way, you can prevent the user from executing any work flow of the system. You can refer the same thing from the line-96 of hr_holidays_view.xml.

Thanks.

Revision history for this message
Best Olivier Dony (Odoo) (odo-openerp) said :
#3

Hello Colin,

Following-up to you question, I think it has not been made very clear how the "Required Group" option affects the workflow transition.
What effectively happens inside workflows is that a transition will "fire" in the following manner:
- if a "signal" is set on the transition, that signal must be sent to the workflow for the transition to fire. Signals are usually sent by buttons of type "workflow".
- if a "condition" is set on the transition, it will prevent firing until the condition evaluates to "True" (even if a signal is received)
- if a "signal" *and* "Required Group" are set on the transition, it will prevent firing (even if the condition evaluates to True) until the given signal is sent by a user who belongs to the "Required group". A signal sent by someone else will just be ignored by the worflow.

As buttons are the usual way to send signals, having the signal should mean that when you press the button (type=workflow) nothing happens, and this is indeed the case. However OpenERP has an additional mechanism built-in in views so that workflow buttons are also displayed disabled (kind of grayed out) when the current workflow state of the document has only one possible transition associated with that button, and the user does not belong to the "Required Group" for that transition.
This is to avoid users clicking on the button and wondering why it doesn't react. Moreover, we usually hide the button completely using different techniques (as mentioned by Amit) when it would only confuse users.

Note that this mechanism of disabling the workflow buttons is done server-side, so you need to close and reopen the forms/menus in your client to notice the difference (logout/login if you want to be sure).

And one more thing: do not test the flows as the Administrator! This is because the Administrator is not restricted by the "Required Group" on a transition, even when he does not belong to that required group.

To conclude, in your example of the purchase order workflow, if you modify the transition from Draft to Confirmed as follows:
- condition = True
- signal = "purchase_confirm" (to be sent by the corresponding button in purchase order form)
- group = "Purchase / Manager"
and make sure to save the change and also logout/login with a non-admin account, you should see that the "Convert to Purchase Order" button on Quotations becomes grayed out automatically if the current user is not member of the "Purchase / Manager" group.

I hope this helps...

Revision history for this message
Colin MacMillan (colin-macmillan) said :
#4

Hi Olivier, thank you this is a great explanation.
I now have the 'Group Required' field working just as I need.
The main issue I had was needing to logout/login since most of the other security functions do not require this ...
Kind regards,
Colin

Revision history for this message
Colin MacMillan (colin-macmillan) said :
#5

Thanks Olivier Dony (OpenERP), that solved my question.