Skip to content
  • Categories
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • 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. Openerp 7.0开发文档中Fuctional fields的纰漏

Openerp 7.0开发文档中Fuctional fields的纰漏

Scheduled Pinned Locked Moved Odoo 文档合作
3 Posts 2 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    laoliu
    wrote on last edited by
    #1

    在openerp官方文档中, 以及国内社区流行的开发手册中, 对Fuctional fields是这样描述:
    fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type="float",fnct_search=None, obj=None, method=False, store=False, multi=False


    其中,如果参数method 指定为true,则fnct和fnct_inv是对象的方法, 其原型为
    def fnct(self, cr, uid, ids, field_name, ....

    而如果参数method指定为False (或不指定,因False为缺省值),则fnct和fnct_inv是全函数,原型为
    def fnct(cr, table, ids, field_name, ...

    然而,在open erp 7.0实现的各个业务模块源码中,我们看到的Fuctional fields没有指定参数method, 而fnct的原型是def fnct(self, cr.... 这种所谓参数method指定为true的方式。难道在openerp 7.0中,参数method的默认值由False 改成了 False了?

    常言说的好, 源码就是最好的文档。 让我们看看实现Fuctional fields的文档吧, 它位于osv/fields.py之中。 源码从第844行开始有连续近200行的注释, 只字未提参数method, 对fnct的原型介绍也修改成了这个样子::

    def fnct(model, cr, uid, ids, field_name, ...
        其中 model: model to which the field belongs (should be self for a model method)


    也就是说, 在openerp 7.0中,定义Fuctional field时 已经不再使用参数method. 不论是对象的方法还是全局函数, fnct的原型都一样了。在openerp官方最新版的技术备忘录中,已经就此做了修改。
    [img http://ww3.sinaimg.cn/bmiddle/53d31817jw1eb403jmq1tj20j60awtap.jpg /img]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      thm1118
      wrote on last edited by
      #2

      真棒,我也奇怪method从没看到

      1 Reply Last reply
      0

      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
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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