【问题标题】:Odoo record rule restrictionsOdoo 记录规则限制
【发布时间】:2017-08-22 16:37:13
【问题描述】:

我想要发生的事情:

当布尔 no_edit 为 False 且 user_id 为 false 或当前用户时,用户应该能够编辑记录。

实际发生的情况:

记录总是被限制编辑。

字段的 Python 代码:

user_id = fields.Many2one(
        comodel_name = 'res.users',
        string = 'User ID',
        readonly = True,
    )
no_edit = fields.Boolean(
        string = "No Edit",
        copy = False,
        default = False
    )

域:

['&', '|', ('no_edit', '=', False), ('user_id', '=', False), ('user_id', '=', user.id)]

提前致谢

【问题讨论】:

  • 你把这个域放在哪里?那里的用户是什么?,您是否尝试使用 [('no_edit', '=', False), '|', ('user_id', '=', False), ('user_id', '=', user. id)]
  • 将域放在只适用于记录写入的记录规则中
  • @dccdany 刚刚尝试了您的建议,它似乎有效。不知道为什么我的最后没有导致它是一样的,不是吗?
  • 我会在答案中回复:)

标签: python-2.7 openerp odoo-8 record-rules


【解决方案1】:

域名应该是:

[('no_edit', '=', False), '|', ('user_id', '=', False), ('user_id', '=', user.id)]

您所做的将第一部分评估为 & 运算符:

('user_id', '=', False) & ('user_id', '=', user.id)

因为它是用“反向波兰表示法”评估的,更多信息您可以搜索或输入这个链接:

https://en.wikipedia.org/wiki/Reverse_Polish_notation

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    • 2018-02-12
    • 2016-08-07
    • 1970-01-01
    • 2020-01-31
    • 2017-04-16
    • 1970-01-01
    相关资源
    最近更新 更多