Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4926 มุมมอง

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!

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ส.ค. 17
4077
1
ม.ค. 17
2853
Odoo 10 Create a new module แก้ไขแล้ว
3
ต.ค. 17
30666
0
มิ.ย. 25
2311
2
พ.ย. 24
1190