Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse

Odoo 中文社区

  1. Home
  2. Categories
  3. Odoo 培训
  4. 计算字段中的compute_sudo

计算字段中的compute_sudo

Scheduled Pinned Locked Moved Odoo 培训
odoo技术compute字段
1 Posts 1 Posters 611 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • digitalsatoriD Offline
    digitalsatoriD Offline
    digitalsatori 管理员
    wrote on last edited by
    #1

    我们在定义一个计算字段时往往会忽略这个计算字段被触发重算的环境。尤其是这个字段depends其它对象的字段,或者我们的运行环境是 多公司的环境。这时候很可能一个没有权限用户对某个字段的修改触发了计算字段的重算,但是因为权限关系这个重算无法完成,从而会出现权限错误。

    当你在遇到这种情况时,就要考虑给计算字段加compute_sudo的属性,比如:

    total_cost = fields.Float('Total Cost', compute='_compute_total', store=True, compute_sudo=True)
    

    注意这种用法只对,store=True的计算字段有效。

    【上海先安科技】(tony AT openerp.cn)

    1 Reply Last reply
    0

    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Tags
    • Popular
    • Users
    • Groups