我的目标是添加采购订单规则以仅显示选定用户组中当前用户创建的采购订单。
我试图应用这条规则:

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

但是当试图查看采购订单时,它会给我以下错误。
OpenERP Server Error

Client Traceback (most recent call last):
  File "/opt/openerp/server/openerp/addons/web/http.py", line 204, in dispatch
    response["result"] = method(self, **self.params)
  File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1051, in search_read
    return self.do_search_read(req, model, fields, offset, limit, domain, sort)
  File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1074, in do_search_read
    req.context)
  File "/opt/openerp/server/openerp/addons/web/session.py", line 42, in proxy
    result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)
  File "/opt/openerp/server/openerp/addons/web/session.py", line 30, in proxy_method
    result = self.session.send(self.service_name, method, *args)
  File "/opt/openerp/server/openerp/addons/web/session.py", line 103, in send
    raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)


Server Traceback (most recent call last):
  File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/server/openerp/osv/osv.py", line 132, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/server/openerp/osv/osv.py", line 199, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp/server/openerp/osv/orm.py", line 2372, in search
    return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count)
  File "/opt/openerp/server/openerp/osv/orm.py", line 4936, in _search
    self._apply_ir_rules(cr, user, query, 'read', context=context)
  File "/opt/openerp/server/openerp/osv/orm.py", line 4816, in _apply_ir_rules
    rule_where_clause, rule_where_clause_params, rule_tables = rule_obj.domain_get(cr, uid, self._name, mode, context=context)
  File "/opt/openerp/server/openerp/addons/base/ir/ir_rule.py", line 156, in domain_get
    query = self.pool.get(model_name)._where_calc(cr, SUPERUSER_ID, dom, active_test=False)
  File "/opt/openerp/server/openerp/osv/orm.py", line 4761, in _where_calc
    e = expression.expression(cr, user, domain, self, context)
  File "/opt/openerp/server/openerp/osv/expression.py", line 646, in __init__
    self.parse(cr, uid, context=context)
  File "/opt/openerp/server/openerp/osv/expression.py", line 810, in parse
    raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf)))
ValueError: Invalid field 'order_id.user_id' in leaf "<osv.ExtendedLeaf: ('order_id.user_id', '=', 14) on purchase_order (ctx: )>"

你能给我个建议吗?
谢谢您,

最佳答案

出现此错误的原因是in purhcase.order object thes is no field nameuser_id.
试试这个,

['|',('order_id.validator','=',user.id),('order_id.validator','=',False)]

关于python - OpenERP 7自定义采购订单规则,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25973877/

10-09 08:59