Skip to Content
Menu
This question has been flagged
1 Reply
1787 Views

Hello,

Whenever trying to add a new product, I face the below error message. I am using Odoo 10 community. Enabled variants for products and added 2 different attributes and the relevant values.

Will appreciate your help.

---

Traceback (most recent call last):
  File "/odoo/odoo-server/odoo/http.py", line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/odoo/odoo-server/odoo/http.py", line 677, in dispatch
    result = self._call_function(**self.params)
  File "/odoo/odoo-server/odoo/http.py", line 333, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/odoo/odoo-server/odoo/service/model.py", line 101, in wrapper
    return f(dbname, *args, **kwargs)
  File "/odoo/odoo-server/odoo/http.py", line 326, in checked_call
    result = self.endpoint(*a, **kw)
  File "/odoo/odoo-server/odoo/http.py", line 935, in __call__
    return self.method(*args, **kw)
  File "/odoo/odoo-server/odoo/http.py", line 506, in response_wrap
    response = f(*args, **kw)
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 885, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/odoo/odoo-server/addons/web/controllers/main.py", line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/odoo/odoo-server/odoo/api.py", line 679, in call_kw
    return call_kw_model(method, model, args, kwargs)
  File "/odoo/odoo-server/odoo/api.py", line 664, in call_kw_model
    result = method(recs, *args, **kwargs)
  File "/odoo/odoo-server/odoo/models.py", line 1122, in default_get
    defaults[name] = field.default(self)
  File "/odoo/odoo-server/addons/product/models/product_template.py", line 23, in _get_default_category_id
    return category.id if category.type == 'normal' else False
AttributeError: 'NoneType' object has no attribute 'type'

---

Avatar
Discard
Best Answer

Hi, Did you checked value in category? You have to check for category first. Like below code,

 return category.id if category and category.type == 'normal' else False

Let me know if it helps.

Thanks!

Avatar
Discard