计算字段中的compute_sudo
-
我们在定义一个计算字段时往往会忽略这个计算字段被触发重算的环境。尤其是这个字段
depends其它对象的字段,或者我们的运行环境是 多公司的环境。这时候很可能一个没有权限用户对某个字段的修改触发了计算字段的重算,但是因为权限关系这个重算无法完成,从而会出现权限错误。当你在遇到这种情况时,就要考虑给计算字段加
compute_sudo的属性,比如:total_cost = fields.Float('Total Cost', compute='_compute_total', store=True, compute_sudo=True)注意这种用法只对,
store=True的计算字段有效。
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login