gpt4 book ai didi

python - 如何检查管理员或用户是否已登录odoo

转载 作者:行者123 更新时间:2023-11-28 21:11:09 25 4
gpt4 key购买 nike

目前我正在用odoo开发一个模块。在我的模块中,用户只能编辑自己的数据,但管理员可以做任何事情。但是我的代码管理员也无法编辑。如果我知道管理员已登录,那么我可以绕过管理员帐户。那么如何知道管理员何时登录?

def write(self, vals):
//if admin is logged in i need to bypass the below code//
if self.create_uid != self.env.user:
raise Warning('You can not able to edit this document as this is not your record')
return super(request_room, self).write(vals)

最佳答案

您想使用 super 用户(管理员)ID。可能是 id = 1下面的代码可以解决问题。

from openerp import SUPERUSER_ID
def write(self, vals):
//if admin is logged in i need to bypass the below code//
if self.create_uid != self.env.user and self.create_uid != SUPERUSER_ID:
raise Warning('You can not able to edit this document as this is not your record')
return super(request_room, self).write(vals)

关于python - 如何检查管理员或用户是否已登录odoo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35692956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com