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. Fields.function store=True 执行次数的问题(已解决)

Fields.function store=True 执行次数的问题(已解决)

Scheduled Pinned Locked Moved Odoo 开发与实施交流
5 Posts 3 Posters 3.6k 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.
  • W Offline
    W Offline
    wang
    wrote on last edited by
    #1

    今天遇见了一个问题 就是在fields.function 的字段声明的时候 ,在store=True的情况下 函数还是在每次对象write的情况下都要执行一次,这样的情况下会很耗性能

    经过jeff的帮助下 找到了一个解决方法 就是在store={'对象':(不变的字段)} 例如::

    'delivery_date': fields.function (day_date_delivery,type="char",
                                              store={'mrp.production': (lambda self, cr, uid, ids, c={}: ids, ['name'], 10),}, string='送货日期'),


    就能很好的解决问题!这个应该是官方修改出来的bug还是一个什么情况 有点时候我们很像实现每次编辑的重新执行函数一次。。以前还有没有这个问题 。现在要是用store=True就要小心点了!!


    听jeff说 上海-Joshua  说过这样一句话  store=true 相当于 store = {self._name:(lambda self, cr, uid, ids, c={}: ids, [ ], 10) }

    希望对大家有 帮助




    1 Reply Last reply
    0
    • 阿 Offline
      阿 Offline
      阿狸
      wrote on last edited by
      #2

      【大校】上海-开阖Jeff(85822082) 2014-08-06 21:41:00查看前后消息
      @上海-Joshua 大神曾经说过,store=true 相当于 store = {self._name:(lambda self, cr, uid, ids, c={}: ids, None, 10)

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wang
        wrote on last edited by
        #3

        http://stuartl.longlandclan.yi.org/blog/2013/04/05/openerp-function-store/ 再次发个连接  ccdos提供 感觉不错

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xtjie
          wrote on last edited by
          #4

          function字段,看源码里的说明,解释的最详细

          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