Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

AttributeError: 'bool' object has no attribute '_setup_fields'

By
Nehemias Herrera
on 2/13/15, 10:23 AM 1,467 views

Hi, I am using nightly version 8.0.20141208, after trying to install my module, I am getting this error

Traceback (most recent call last):
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 517, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 538, in dispatch
    result = self._call_function(**self.params)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 294, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 291, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 754, in __call__
    return self.method(*args, **kw)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 387, in response_wrap
    response = f(*args, **kw)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/web/controllers/main.py", line 953, in call_button
    action = self._call_kw(model, method, args, {})
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/web/controllers/main.py", line 941, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/base/module/module.py", line 450, in button_immediate_install
    return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/addons/base/module/module.py", line 498, in _button_immediate_function
    registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 341, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 358, in load_modules
    loaded_modules, update_module)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 263, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 162, in load_module_graph
    registry.setup_models(cr, partial=True)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 169, in setup_models
    model._setup_fields(cr, SUPERUSER_ID, context=context)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 332, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 2963, in _setup_fields
    field.setup(self.env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 411, in setup
    self._setup(env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 1374, in _setup
    super(_Relational, self)._setup(env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 419, in _setup
    self._setup_regular(env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 1659, in _setup_regular
    comodel._setup_fields()
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 235, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 2963, in _setup_fields
    field.setup(self.env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 411, in setup
    self._setup(env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 417, in _setup
    self._setup_related(env)
  File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 448, in _setup_related
    recs._setup_fields()
AttributeError: 'bool' object has no attribute '_setup_fields'


There's not a single bool field in my code, I can't understand the reason of the error, thanks.

Looks like 'recs' gets return False from call rather then recordset. Try to add a check in your code.

Chris Z.
on 2/13/15, 10:45 AM

please read the post below, this error was happening because I changed _inherits = {'res.partner':'partner_id'} for _inherits = {'res.partner':'id'}

Nehemias Herrera
on 2/13/15, 6:07 PM
0
Nehemias Herrera
On 2/13/15, 6:02 PM

The previous error comes after I made a modification to my model, I am trying to inherit from res.partner, I copied the code from res_users.py since it already inherits from res.partner, so, this is my model:


# -*- coding: utf-8 -*-
from openerp import fields
from openerp import models

class Test (models.Model):
    _name = 'test'
    _inherits = {'res.partner':'partner_id'}

    sample_field = fields.Char(string="Field")

with it I get this error:


[Fri Feb 13 22:44:17.770757 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0] mod_wsgi (pid=2125): Exception occurred processing WSGI script '/opt/bitnami/apps/odoo/scripts/openerp.wsgi'.
[Fri Feb 13 22:44:17.770846 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0] Traceback (most recent call last):
[Fri Feb 13 22:44:17.770878 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/wsgi_server.py", line 216, in application
[Fri Feb 13 22:44:17.772492 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return application_unproxied(environ, start_response)
[Fri Feb 13 22:44:17.772544 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/wsgi_server.py", line 202, in application_unproxied
[Fri Feb 13 22:44:17.772588 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     result = handler(environ, start_response)
[Fri Feb 13 22:44:17.772599 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 1236, in __call__
[Fri Feb 13 22:44:17.774421 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return self.dispatch(environ, start_response)
[Fri Feb 13 22:44:17.774467 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 1210, in __call__
[Fri Feb 13 22:44:17.774506 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return self.app(environ, start_wrapped)
[Fri Feb 13 22:44:17.774530 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/python/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/wsgi.py", line 411, in __call__
[Fri Feb 13 22:44:17.775786 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return self.app(environ, start_response)
[Fri Feb 13 22:44:17.775820 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 1368, in dispatch
[Fri Feb 13 22:44:17.775900 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     ir_http = request.registry['ir.http']
[Fri Feb 13 22:44:17.775923 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/http.py", line 330, in registry
[Fri Feb 13 22:44:17.775946 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
[Fri Feb 13 22:44:17.775960 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 310, in get
[Fri Feb 13 22:44:17.776184 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     update_module)
[Fri Feb 13 22:44:17.776207 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 341, in new
[Fri Feb 13 22:44:17.776232 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     openerp.modules.load_modules(registry._db, force_demo, status, update_module)
[Fri Feb 13 22:44:17.776245 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 354, in load_modules
[Fri Feb 13 22:44:17.776444 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     force, status, report, loaded_modules, update_module)
[Fri Feb 13 22:44:17.776466 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 263, in load_marked_modules
[Fri Feb 13 22:44:17.776492 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
[Fri Feb 13 22:44:17.776506 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 228, in load_module_graph
[Fri Feb 13 22:44:17.776523 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     registry.setup_models(cr, partial=True)
[Fri Feb 13 22:44:17.776535 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 169, in setup_models
[Fri Feb 13 22:44:17.776552 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     model._setup_fields(cr, SUPERUSER_ID, context=context)
[Fri Feb 13 22:44:17.776568 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 237, in wrapper
[Fri Feb 13 22:44:17.776851 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     return old_api(self, *args, **kwargs)
[Fri Feb 13 22:44:17.776881 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/api.py", line 332, in old_api
[Fri Feb 13 22:44:17.776898 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     result = method(recs, *args, **kwargs)
[Fri Feb 13 22:44:17.776916 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 2963, in _setup_fields
[Fri Feb 13 22:44:17.778493 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     field.setup(self.env)
[Fri Feb 13 22:44:17.778531 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 411, in setup
[Fri Feb 13 22:44:17.779042 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     self._setup(env)
[Fri Feb 13 22:44:17.779066 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 417, in _setup
[Fri Feb 13 22:44:17.779095 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     self._setup_related(env)
[Fri Feb 13 22:44:17.779109 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]   File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/fields.py", line 449, in _setup_related
[Fri Feb 13 22:44:17.779125 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0]     field = recs._fields[name]
[Fri Feb 13 22:44:17.779157 2015] [:error] [pid 2125:tid 139651321841408] [remote 192.168.2.64:0] KeyError: 'partner_id'

If I remove  _inherits = {'res.partner':'partner_id'}  it works fine, I don't understand why is this giving me an error if I am inheriting the same way res_users.py does it https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/res/res_users.py#L143-L145

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/13/15, 10:48 AM

It is not refering to Boolean (not bool) fields but the fact (from the error message) recs has no value, which is usually assigned as False and hence has bool type.  The error is generated (from the tracebak) from _setup_related method, which, according to the source code: Setup the attributes of a related field.  So, I would suggest that you check any fields that has related attribute.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/13/15, 10:23 AM
Seen: 1467 times
Last updated: 3/16/15, 8:10 AM