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. 使用 `dp.get_precision('xxx')` 来定义浮点数字段的预设数字精度已经淘汰了

使用 `dp.get_precision('xxx')` 来定义浮点数字段的预设数字精度已经淘汰了

Scheduled Pinned Locked Moved Odoo 培训
floatfielddigitsprecisionodoo技术
1 Posts 1 Posters 1.4k Views
  • 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.
  • D Offline
    D Offline
    digitalsatori
    管理员
    wrote on last edited by
    #1

    在V13以前,我们可以用下面的方法来为浮点数字段设置预设的数字精度:

    import odoo.addons.decimal_precision as dp
    
    xxx = fields.Float(digits=dp.get_precision("Account"))
    

    这个定义对用户很友好,这表示xxx字段可以使用一个叫Account的浮点数的小数点位数的定义。如果用户对xxx字段的精度不满意,就可以找到Account这个预设精度,改变精度值,xxx字段的精度也相应改变了。没有这个设计,改变浮点数精度必须依赖程序员修改代码。

    V13把目前的这个定义方式淘汰了,变得更加简单:

    xxx = fields.Float(digits="Account")
    

    注意没有了import, 和dp.get_precision

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

    1 Reply Last reply
    1

    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