I'm using Odoo Studio to create a model that includes a m2o field to the employee model, and I need to set it's domain to an specific category.
I created an employee and I assigned the category "Operario"
I created a new model in Odoo Studio with a m2o field to the hr.employee model and I added the next domain: [["category_ids.name","in","Operario"]]
I tried to create a new registry in the new model but when I click on the o2m field I got this error if I'm not a member of the HR security group:
ValueError: Invalid field hr.employee.public.category_ids in leaf ('category_ids.name', 'in', 'Operario')
Whole code:
Traceback (most recent call last):
File "/home/odoo/src/odoo/14.0/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 683, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 359, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/14.0/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 347, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 912, in __call__
return self.method(*args, **kw)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 531, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/14.0/addons/web/controllers/main.py", line 1377, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/14.0/addons/web/controllers/main.py", line 1369, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/14.0/odoo/api.py", line 392, in call_kw
result = _call_kw_model(method, model, args, kwargs)
File "/home/odoo/src/odoo/14.0/odoo/api.py", line 365, in _call_kw_model
result = method(recs, *args, **kwargs)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1796, in name_search
ids = self._name_search(name, args, operator, limit=limit)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 1812, in _name_search
return self._search(args, limit=limit, access_rights_uid=name_get_uid)
File "/home/odoo/src/odoo/14.0/addons/hr/models/hr_employee.py", line 166, in _search
ids = self.env['hr.employee.public']._search(args, offset=offset, limit=limit, order=order, count=count, access_rights_uid=access_rights_uid)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 4492, in _search
query = self._where_calc(args)
File "/home/odoo/src/odoo/14.0/odoo/models.py", line 4248, in _where_calc
return expression.expression(domain, self).query
File "/home/odoo/src/odoo/14.0/odoo/osv/expression.py", line 438, in __init__
self.parse()
File "/home/odoo/src/odoo/14.0/odoo/osv/expression.py", line 640, in parse
raise ValueError("Invalid field %s.%s in leaf %s" % (model._name, path[0], str(leaf)))
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 639, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/14.0/odoo/http.py", line 315, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Invalid field hr.employee.public.category_ids in leaf ('category_ids.name', 'in', 'Operario')
In the last line of the error details, I see the word public, I'm not sure if that's a sub model, in any case I don't know where to setup those permissions for non HR members.