跳至内容
菜单
此问题已终结
1 回复
4921 查看

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




形象
丢弃
最佳答案

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

形象
丢弃
编写者

thank you!

相关帖文 回复 查看 活动
0
8月 17
4073
1
1月 17
2837
3
10月 17
30648
0
6月 25
2305
2
11月 24
1187