You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo15拉取代码后打开单据报错:无法相减res.partner与res.users模型

Odoo 15拉取代码后打开销售订单报错:无法对不同模型做减法操作

问题描述

从Odoo 15.0仓库拉取最新代码后,打开销售订单及部分自定义对象记录时触发错误,错误信息:

TypeError: cannot substract different models: 'res.partner()' and 'res.users()'

无法定位具体错误位置,需确认是否为Odoo 15新版本BUG。

错误分析

从报错堆栈来看,错误发生在Odoo的表达式解析逻辑中,具体是parent_of_domain函数尝试对res.partner和res.users的记录集执行减法操作,而Odoo明确禁止不同模型的记录集进行此类运算。

这基本不是Odoo官方核心的BUG,官方代码不会出现这种跨模型操作的低级错误,更可能是以下原因导致:

  • 自定义模块(如堆栈中出现的edoo_custom_treeview)修改了搜索逻辑,导致混用了不同模型的记录集。
  • 自定义的搜索面板配置、域名过滤规则中,错误使用了parent_of操作符,传递了跨模型的参数。

排查与解决步骤

  • 先禁用可疑自定义模块:优先禁用堆栈中出现的edoo_custom_treeview模块,重新测试是否还会触发错误。如果问题消失,说明该模块是错误源头,需要修复其代码逻辑,确保记录集操作的模型一致性。
  • 检查搜索面板配置:查看销售订单及自定义对象的搜索面板,是否有针对用户或合作伙伴的层级过滤设置,确认是否错误关联了不同模型。
  • 排查自定义域名逻辑:检查所有自定义模块中涉及parent_of操作符的域名代码,确保传递的记录集属于同一个模型。

完整报错堆栈

Traceback (most recent call last):
  File "/home/cicindela/V15/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/home/cicindela/V15/odoo/odoo/http.py", line 698, in dispatch
    result = self._call_function(**self.params)
  File "/home/cicindela/V15/odoo/odoo/http.py", line 368, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/cicindela/V15/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/cicindela/V15/odoo/odoo/http.py", line 357, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/cicindela/V15/odoo/odoo/http.py", line 921, in __call__
    return self.method(*args, **kw)
  File "/home/cicindela/V15/odoo/odoo/http.py", line 546, in response_wrap
    response = f(*args, **kw)
  File "/home/cicindela/V15/cicindela/deep/edoo_custom_treeview/controllers/main.py", line 12, in call_kw
    call_kw_result = super(LvmController, self).call_kw(model, method, args, kwargs, path)
  File "/home/cicindela/V15/odoo/odoo/http.py", line 546, in response_wrap
    response = f(*args, **kw)
  File "/home/cicindela/V15/odoo/addons/web/controllers/main.py", line 1324, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/cicindela/V15/odoo/addons/web/controllers/main.py", line 1316, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/cicindela/V15/odoo/odoo/api.py", line 460, in call_kw
    result = _call_kw_model(method, model, args, kwargs)
  File "/home/cicindela/V15/odoo/odoo/api.py", line 433, in _call_kw_model
    result = method(recs, *args, **kwargs)
  File "/home/cicindela/V15/odoo/addons/web/models/models.py", line 571, in search_panel_select_range
    comodel_records = Comodel.search_read(comodel_domain, field_names, limit=limit)
  File "/home/cicindela/V15/odoo/odoo/models.py", line 5044, in search_read
    records = self.search(domain or [], offset=offset, limit=limit, order=order)
  File "/home/cicindela/V15/odoo/odoo/models.py", line 1810, in search
    res = self._search(args, offset=offset, limit=limit, order=order, count=count)
  File "/home/cicindela/V15/odoo/odoo/addons/base/models/res_users.py", line 559, in _search
    return super(Users, self)._search(args, offset=offset, limit=limit, order=order, count=count,
  File "/home/cicindela/V15/odoo/odoo/models.py", line 4711, in _search
    query = self._where_calc(args)
  File "/home/cicindela/V15/odoo/odoo/models.py", line 4467, in _where_calc
    return expression.expression(domain, self).query
  File "/home/cicindela/V15/odoo/odoo/osv/expression.py", line 442, in __init__
    self.parse()
  File "/home/cicindela/V15/odoo/odoo/osv/expression.py", line 668, in parse
    dom = HIERARCHY_FUNCS[operator](left, ids2, model)
  File "/home/cicindela/V15/odoo/odoo/osv/expression.py", line 576, in parent_of_domain
    records = records[parent_name] - records.browse(parent_ids)
  File "/home/cicindela/V15/odoo/odoo/models.py", line 5799, in __sub__
    raise TypeError(f"cannot substract different models: '{self._name}()' and '{other._name}()'")

内容的提问来源于stack exchange,提问作者Lalit Patidar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 19:39:53