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

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

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

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

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

odoo判断 用户是否是销售团队负责人的规则



  • domain [('team_id','ilike',user.sale_team_id.name),(user.id,'=',user.sale_team_id.user_id.id)];

    报错
    错误:
    Odoo Server Error

    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 619, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 309, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
    File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
    raise value
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 664, in dispatch
    result = self._call_function(**self.params)
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 345, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 338, in checked_call
    result = self.endpoint(*a, **kw)
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 909, in call
    return self.method(*args, **kw)
    File "/usr/lib/python3/dist-packages/odoo/http.py", line 510, in response_wrap
    response = f(*args, **kw)
    File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1277, in search_read
    return self.do_search_read(model, fields, offset, limit, domain, sort)
    File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1296, in do_search_read
    return Model.web_search_read(domain, fields, offset=offset, limit=limit, order=sort)
    File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 36, in web_search_read
    records = self.search_read(domain, fields, offset=offset, limit=limit, order=order)
    File "/usr/lib/python3/dist-packages/odoo/models.py", line 4793, in search_read
    records = self.search(domain or [], offset=offset, limit=limit, order=order)
    File "/usr/lib/python3/dist-packages/odoo/models.py", line 1600, in search
    res = self._search(args, offset=offset, limit=limit, order=order, count=count)
    File "/usr/lib/python3/dist-packages/odoo/models.py", line 4339, in _search
    self._apply_ir_rules(query, 'read')
    File "/usr/lib/python3/dist-packages/odoo/models.py", line 4137, in _apply_ir_rules
    where_clause, where_params, tables = Rule.domain_get(self._name, mode)
    File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_rule.py", line 187, in domain_get
    query = self.env[model_name].sudo()._where_calc(dom, active_test=False)
    File "/usr/lib/python3/dist-packages/odoo/models.py", line 4076, in _where_calc
    e = expression.expression(domain, self)
    File "/usr/lib/python3/dist-packages/odoo/osv/expression.py", line 674, in init
    self.parse()
    File "/usr/lib/python3/dist-packages/odoo/osv/expression.py", line 811, in parse
    self.stack = [ExtendedLeaf(leaf, self.root_model) for leaf in self.expression]
    File "/usr/lib/python3/dist-packages/odoo/osv/expression.py", line 811, in
    self.stack = [ExtendedLeaf(leaf, self.root_model) for leaf in self.expression]
    File "/usr/lib/python3/dist-packages/odoo/osv/expression.py", line 559, in init
    self.check_leaf(internal)
    File "/usr/lib/python3/dist-packages/odoo/osv/expression.py", line 615, in check_leaf
    raise ValueError("Invalid leaf %s" % str(self.leaf))
    ValueError: Invalid leaf (41, '=', 41)

    用的docker 的 odoo13开发的


  • 管理员

    @元宝 首先“销售订单”,“漏洞”,”线索“ 对象上要有对应sale_team的外键字段比如team_id . 记得team.user_id就是团队负责人, 所以你的domain可以是:

    [('team_id.user_id', '=', user.id)]
    


  • 或者有没有其他的domain 判断规则 求大佬指教



  • 应用场景是 在访问销售订单的时候 判断这个人是不是销售团队的负责人



  • @元宝 添加一个计算字段就可以搞定



  • @andy-huang 是在res.user里添加一个字段 用来计算吗。有具体步骤逻辑吗。公司业务需求 刚学odoo 还没太明白



  • @digitalsatori 大佬能提供思路吗


  • 管理员

    感觉你的问题的标题和内容不搭啊。
    domain不是用来判断用户是否为销售团队负责人的,domain是用来作为过滤条件过滤记录的。你是要在什么对象上使用domain,想要如何过滤记录。



  • @digitalsatori 我现在大概了解了。用domain 无法过滤。



  • @digitalsatori 我的业务需求 是一个用户可以是多个团队负责人。然后可以查看负责团队的销售订单 或者 漏洞/线索。 这个大概是往哪个方向 入手。我看楼上说的添加一个计算字段 是什么逻辑。


  • 管理员

    @元宝 首先“销售订单”,“漏洞”,”线索“ 对象上要有对应sale_team的外键字段比如team_id . 记得team.user_id就是团队负责人, 所以你的domain可以是:

    [('team_id.user_id', '=', user.id)]
    


  • @digitalsatori 谢谢 已解决 怎么标记这个问题已解决


  • 管理员

    不客气,常来交流。在“主题工具”里可以标记“问题已解决”。我已经帮你标记了。


Log in to reply