【问题标题】:Odoo domain filter isn't workingOdoo 域过滤器不起作用
【发布时间】:2017-08-16 13:33:52
【问题描述】:

我尝试创建一个如下所示的域过滤器:

(Followup date < today) AND (customer = TRUE OR user_id = user.id)

我是这样做的:

[('follow_up_date', '&lt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),['|', ('customer', '=', 'False'),('user_id', '=', 'user.id')]]

如果第一部分(时间过滤器)单独使用,效果很好,但是当我将它与第二部分连接时,就像我在上面的示例中所做的那样,它会给我这个错误:

 File "/usr/lib/python2.7/dist-packages/openerp/osv/expression.py", line 308, in distribute_not
    elif token in DOMAIN_OPERATORS_NEGATION:
TypeError: unhashable type: 'list'

怎么了,我该如何表达我想要的正确的域过滤器?

提前感谢您的帮助:)

【问题讨论】:

    标签: openerp odoo-8 erp


    【解决方案1】:

    Odoo 使用polish notation。如果您想使用逻辑表达式 (A) AND (B OR C) 作为域,这意味着您必须使用:AND A OR B C。如果您想了解有关波兰符号的更多信息,请查看链接。

    这意味着,如果我正确理解了这个问题,您将需要这个:

    ['&', ('follow_up_date', '&lt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),'|', ('customer', '=', 'False'),('user_id', '=', 'user.id')]
    

    【讨论】:

      【解决方案2】:

      尝试在第二个表达式中不使用括号:

      [('follow_up_date', '&lt;=', datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')),'|', ('customer', '=', 'False'),('user_id', '=', 'user.id')']
      

      希望对你有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-09-15
        • 2022-11-24
        • 1970-01-01
        • 2016-08-07
        相关资源
        最近更新 更多