Search code examples
pythonodooodoo-15

how to fix External ID not found in the system on user create button?


I'm pretty new in Odoo, for the moment I dind't modified any code but this error is persistent when I try to create a new product.

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "/opt/odoo/odoo/odoo/tools/func.py", line 71, in wrapper
    return func(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('product.template', <function ProductTemplate._get_default_category_id at 0x7f77854ab490>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/tools/cache.py", line 85, in lookup
    r = d[key]
  File "/opt/odoo/odoo/odoo/tools/func.py", line 71, in wrapper
    return func(self, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/tools/lru.py", line 34, in __getitem__
    a = self.d[obj]
KeyError: ('ir.model.data', <function IrModelData._xmlid_lookup at 0x7f778a47b1c0>, 'product.product_category_all')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
    result = request.dispatch()
  File "/opt/odoo/odoo/odoo/http.py", line 687, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/odoo/odoo/http.py", line 359, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/http.py", line 348, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/odoo/odoo/http.py", line 916, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/odoo/odoo/http.py", line 535, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1347, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/odoo/addons/web/controllers/main.py", line 1339, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/odoo/odoo/api.py", line 464, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/odoo/odoo/api.py", line 451, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/odoo/odoo/models.py", line 6356, in onchange
    defaults = self.default_get(missing_names)
  File "/opt/odoo/odoo/odoo/models.py", line 1410, in default_get
    defaults[name] = field.default(self)
  File "<decorator-gen-151>", line 2, in _get_default_category_id
  File "/opt/odoo/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/odoo/addons/product/models/product_template.py", line 24, in _get_default_category_id
    return self.env.ref('product.product_category_all')
  File "/opt/odoo/odoo/odoo/api.py", line 578, in ref
    res_model, res_id = self['ir.model.data']._xmlid_to_res_model_res_id(
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_model.py", line 1935, in _xmlid_to_res_model_res_id
    return self._xmlid_lookup(xmlid)[1:3]
  File "<decorator-gen-35>", line 2, in _xmlid_lookup
  File "/opt/odoo/odoo/odoo/tools/cache.py", line 90, in lookup
    value = d[key] = self.method(*args, **kwargs)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_model.py", line 1928, in _xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % xmlid)
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/http.py", line 643, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/odoo/odoo/http.py", line 301, in _handle_exception
    raise exception.with_traceback(None) from new_cause
ValueError: External ID not found in the system: product.product_category_all

A little of backstory, I imported a lot of products, atributes and categories and did some testing deleting and importing again that is probably the origin of the issue.


Solution

  • The external ID product.product_category_all should be one of the default product categories introduced/installed by the app/module "product".

    Obviously Odoo is using this one as a default value and you get an error, because it was deleted.

    The easiest fix is to just update the app/module "product". Odoo will recreate the category and the error should be gone.