Odoo 中文社区

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

    由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

    本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

    开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

    如果您登录系统碰到问题,请在微信公众号留言:

    Solved 如何判断某元素存在于

    Odoo 开发与实施交流
    2
    6
    89
    Loading More Posts
    • 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
      steven last edited by

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

      digitalsatori 1 Reply Last reply Reply Quote 0
      • digitalsatori
        digitalsatori 管理员 @steven last edited by

        @Steven 可以用

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

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

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

        S 1 Reply Last reply Reply Quote 0
        • digitalsatori
          digitalsatori 管理员 @steven last edited by

          @Steven 可以用

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

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

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

          S 1 Reply Last reply Reply Quote 0
          • S
            steven @digitalsatori last edited by

            @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
            ”
            若方便,还请赐教。

            digitalsatori 1 Reply Last reply Reply Quote 0
            • digitalsatori
              digitalsatori 管理员 @steven last edited by

              @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 Reply Quote 0
              • S
                steven @digitalsatori last edited by 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两边的单引号去掉后,程序恢复了正常。

                digitalsatori 1 Reply Last reply Reply Quote 0
                • digitalsatori
                  digitalsatori 管理员 @steven last edited by

                  @Steven 感谢你能更新信息

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

                  1 Reply Last reply Reply Quote 0
                  • Topic has been marked as a question  digitalsatori digitalsatori 
                  • Topic has been marked as solved  digitalsatori digitalsatori 
                  • First post
                    Last post