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. 如何判断某元素存在于

如何判断某元素存在于

Scheduled Pinned Locked Moved Solved Odoo 开发与实施交流
6 Posts 2 Posters 4.6k 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.
  • S
    S
    steven
    wrote on last edited by
    #1

    请教:
    我在class里创建了一个many2many字段(即: participator_ids“参与人”可以从所有注册用户里多选)
    92fd37d0-ff9e-4f73-bae8-c407c3e2415d-image.png
    现在,我需要判断目前登录的用户是否存在于participator_ids“参与人”这个字段里。如果存在,就展示在页面筛选器“我参与的任务”里。
    ecc3fb57-d5e8-41f3-8576-f5185c86a249-image.png
    但这条语句中的domain可能不对,python提示无法解释。
    请问该如何实现这个功能?

    digitalsatoriD 1 Reply Last reply
    0
    • S steven

      请教:
      我在class里创建了一个many2many字段(即: participator_ids“参与人”可以从所有注册用户里多选)
      92fd37d0-ff9e-4f73-bae8-c407c3e2415d-image.png
      现在,我需要判断目前登录的用户是否存在于participator_ids“参与人”这个字段里。如果存在,就展示在页面筛选器“我参与的任务”里。
      ecc3fb57-d5e8-41f3-8576-f5185c86a249-image.png
      但这条语句中的domain可能不对,python提示无法解释。
      请问该如何实现这个功能?

      digitalsatoriD
      digitalsatoriD
      digitalsatori
      管理员
      wrote on last edited by
      #2

      @Steven 可以用

      [('participator_ids', 'in', uid)]
      

      把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

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

      S 1 Reply Last reply
      0
      • digitalsatoriD digitalsatori

        @Steven 可以用

        [('participator_ids', 'in', uid)]
        

        把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

        S
        S
        steven
        wrote on last edited by
        #3

        @digitalsatori 在 如何判断某元素存在于 中说:

        @Steven 可以用

        [('participator_ids', 'in', uid)]
        

        把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

        谢谢!
        按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
        “
        File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
        raise ValueError("Invalid domain term %r" % (leaf,))
        Exception
        ”
        若方便,还请赐教。

        digitalsatoriD 1 Reply Last reply
        0
        • S steven

          @digitalsatori 在 如何判断某元素存在于 中说:

          @Steven 可以用

          [('participator_ids', 'in', uid)]
          

          把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

          谢谢!
          按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
          “
          File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
          raise ValueError("Invalid domain term %r" % (leaf,))
          Exception
          ”
          若方便,还请赐教。

          digitalsatoriD
          digitalsatoriD
          digitalsatori
          管理员
          wrote on last edited by
          #4

          @steven 在 如何判断某元素存在于 中说:

          @digitalsatori 在 如何判断某元素存在于 中说:

          @Steven 可以用

          [('participator_ids', 'in', uid)]
          

          把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

          谢谢!
          按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
          “
          File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
          raise ValueError("Invalid domain term %r" % (leaf,))
          Exception
          ”
          若方便,还请赐教。

          如果你确实没有写错的话。升级模块后,有没有刷新应用界面。

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

          S 1 Reply Last reply
          0
          • digitalsatoriD digitalsatori

            @steven 在 如何判断某元素存在于 中说:

            @digitalsatori 在 如何判断某元素存在于 中说:

            @Steven 可以用

            [('participator_ids', 'in', uid)]
            

            把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

            谢谢!
            按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
            “
            File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
            raise ValueError("Invalid domain term %r" % (leaf,))
            Exception
            ”
            若方便,还请赐教。

            如果你确实没有写错的话。升级模块后,有没有刷新应用界面。

            S
            S
            steven
            wrote on last edited by steven
            #5

            @digitalsatori 在 如何判断某元素存在于 中说:

            @steven 在 如何判断某元素存在于 中说:

            @digitalsatori 在 如何判断某元素存在于 中说:

            @Steven 可以用

            [('participator_ids', 'in', uid)]
            

            把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

            谢谢!
            按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
            “
            File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
            raise ValueError("Invalid domain term %r" % (leaf,))
            Exception
            ”
            若方便,还请赐教。

            如果你确实没有写错的话。升级模块后,有没有刷新应用界面。

            问题终于解决了,原来我犯一个低级错误,在domain="[('participator_ids','in','uid')]"里将uid两边的单引号去掉后,程序恢复了正常。

            digitalsatoriD 1 Reply Last reply
            0
            • S steven

              @digitalsatori 在 如何判断某元素存在于 中说:

              @steven 在 如何判断某元素存在于 中说:

              @digitalsatori 在 如何判断某元素存在于 中说:

              @Steven 可以用

              [('participator_ids', 'in', uid)]
              

              把uid 放在元组的第一个元素是不对的。系统对x2M 类型字段会自动反转过滤条件的。

              谢谢!
              按照您所说的,反转过滤条件,模块升级没有报错。但在“应用”界面内点击过滤菜单,运行过程中出现了问题。
              “
              File "C:\Program Files\Odoo 14.0.20210827\server\odoo\osv\expression.py", line 1010, in __leaf_to_sql
              raise ValueError("Invalid domain term %r" % (leaf,))
              Exception
              ”
              若方便,还请赐教。

              如果你确实没有写错的话。升级模块后,有没有刷新应用界面。

              问题终于解决了,原来我犯一个低级错误,在domain="[('participator_ids','in','uid')]"里将uid两边的单引号去掉后,程序恢复了正常。

              digitalsatoriD
              digitalsatoriD
              digitalsatori
              管理员
              wrote on last edited by
              #6

              @Steven 感谢你能更新信息

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

              1 Reply Last reply
              0
              • digitalsatoriD digitalsatori 将这个主题转为问答主题,在
              • digitalsatoriD digitalsatori 将这个主题标记为已解决,在

              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