2015-05-07 57 views
1

我正在尋找一種方法來檢查登錄用戶是否爲特定模塊(如「銷售點」)的經理。使用SQL我可以檢查這種情況,但是我們可以使用ORM完成相同的操作嗎?如何檢查用戶是否是Odoo中特定模塊的管理員?

以下是其上市誰是「銷售點」模塊管理器的用戶我的SQL查詢:尋找相同的ORM相當或一些其他的方式來實現所需要的東西:

select login, usr.id as user_id, grp.id group_id, grp.name, cat.name 
from res_users usr, res_groups_users_rel rel, res_groups grp, ir_module_category cat 
where usr.id = rel.uid 
and rel.gid = grp.id 
and grp.category_id = cat.id 
and cat.name = 'Point of Sale' 
and grp.name = 'Manager'; 

回答

2

終於完成了:) 以下是我在python中的工作代碼:

models.execute_kw(db, uid, password, 
    'res.users', 'search',[[['id','=',userid],['groups_id.name','=','Manager'],['groups_id.category_id.name','=','Point of Sale']]],{}) 
相關問題