Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
4922 Näkymät

Hello, I want to make an if that checks if the user has manager or user rights like this:

if order.user_has_groups('purchase.group_purchase_user') and order.amount_total > 5000:
raise UserError(_("You can\'t confirm the purchase order, please contact the current purchase manager."))
return False
if order.user_has_groups('purchase.group_purchase_manager'):

My problem now is that the purchase manager has the user rules too. So It goes everytime to the UserError if. 


How can I fix that, that the user with "purchase: user" rights go to the usererror and the "manager" to the other?


Thank you very much




Avatar
Hylkää
Paras vastaus

Hi, Try like this,

Add an extra condition in the if statement,

not order.user_has_group('purchase.group_purchase_manager')

if order.user_has_groups('purchase.group_purchase_user') and not order.user_has_groups('purchase.group_purchase_manager') and order.amount_total > 5000:
raise UserError(_("You can\'t confirm the purchase order, please contact the current purchase manager."))
return False

Avatar
Hylkää
Tekijä

thank you!

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
0
elok. 17
4074
1
tammik. 17
2841
3
lokak. 17
30651
0
kesäk. 25
2308
2
marrask. 24
1187