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. odoo如何处理“空”?

odoo如何处理“空”?

Scheduled Pinned Locked Moved Odoo 新手求助
5 Posts 4 Posters 5.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.
  • E Offline
    E Offline
    eric2017
    wrote on last edited by
    #1

    1.字段是否支持空值?
    例如:数字字段,为空,比为0方便。为0时,在输入数字时,需要先选中0,操作麻烦
    2.下拉框控件是否支持选空值?
    除了Selection,没发现别的下拉框可以选空。在实际使用时,有些是允许为空的,如果不小心选择并保存了,就没有办法清空了。

    H 1 Reply Last reply
    0
    • E eric2017

      1.字段是否支持空值?
      例如:数字字段,为空,比为0方便。为0时,在输入数字时,需要先选中0,操作麻烦
      2.下拉框控件是否支持选空值?
      除了Selection,没发现别的下拉框可以选空。在实际使用时,有些是允许为空的,如果不小心选择并保存了,就没有办法清空了。

      H Offline
      H Offline
      hui
      wrote on last edited by
      #2

      @eric2017
      1.Integer 为空的我不知道

      2.下拉框的Selection可以选择空,对于Many2one的字段类型,会有下拉选项,如果想清空的话,直接在输入框上删除就可以清空了,保存的时候就保存空值的了.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cherrychan
        wrote on last edited by
        #3

        可以试试定义成char类型,使用时再转换

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kowky
          wrote on last edited by
          #4

          个人感觉你这有点矛盾了,你想字段为空,还不想无意间录入数值清空不了,我不太清楚你的需求到底是什么。
          1.如果你就想该字段为空那可以判断 当不为空的时候赋值为空
          2.如果你认为当为数字的时候0麻烦那也可以判断这个字段等于0的时候赋值成空也是可以的

          E 1 Reply Last reply
          0
          • K Kowky

            个人感觉你这有点矛盾了,你想字段为空,还不想无意间录入数值清空不了,我不太清楚你的需求到底是什么。
            1.如果你就想该字段为空那可以判断 当不为空的时候赋值为空
            2.如果你认为当为数字的时候0麻烦那也可以判断这个字段等于0的时候赋值成空也是可以的

            E Offline
            E Offline
            eric2017
            wrote on last edited by
            #5

            @袭流苏2amor
            这是2个问题。问题2非常感谢 @1234567 ,已经回答的很清楚了;下面说问题1:
            数字为空的功能,是用在明细中。当添加明细时,所有数字字段为空,方便输入。而实际中,显示为0(或小数,例如0.00),第一次点击时,会全部选中,可是,从第二个字段起,就需要手动全选删除,再输入数字。这很显然不是一个方便人使用的设计。

            赋值为空的方法,可能没有效果:我给字段的default赋值为None,添加明细时,仍然显示为0。不知道是不是我的方法有问题?

            另:
            感谢 @cherrychan ,我添加了char类型的字段,用于在页面上显示,实际使用时,取对于的数字字段。它有2个问题:
            1.对于需要保留小数位数的字段,需要额外处理
            2.每个数字字段,都需要添加对于的char类型字段,这涉及到大量的修改,即便全部修改完成,也会增加复杂性,不利于理解和以后的维护。
            我觉得,这个处理办法,只能在不得已的情况下采用了。

            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