new Odoo v8 API is breaking interactive session

Bug #1338405 reported by Raphaël Valyi - http://www.akretion.com
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenERP buildout recipe
Fix Released
Critical
Unassigned

Bug Description

Hello,

until Odoo master commit d78192c489d3be66cd6487b39f5ce7ba4733a187 everything works fine.

Now on commit cbe2dbb672a6c55d86f2e515f9d1cdfee426ef80 "[MERGE] new v8 api by rco" from 06/06/2014, if I start a new session I get:

>>> session.registry('ir.module.module').browse(session.cr, 1, 1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/vagrant/dev1/parts/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/vagrant/dev1/parts/odoo/openerp/models.py", line 5030, in browse
    return self._browse(Environment(cr, uid, context or {}), ids)
  File "/home/vagrant/dev1/parts/odoo/openerp/api.py", line 666, in __new__
    env, envs = None, cls._local.environments
  File "/home/vagrant/dev1/eggs/Werkzeug-0.9.6-py2.7.egg/werkzeug/local.py", line 71, in __getattr__
    raise AttributeError(name)
AttributeError: environments

Hope this helps.

Revision history for this message
Georges Racinet (gracinet) wrote :

The call to the context manager that initializes the environments weakset class-level attr is indeed missing.
From registry.py:

            with openerp.api.Environment.manage():
                registry = Registry(db_name)

That should be an easy fix, although care must be taken (version check, check that "local" stands for "thread local" etc.)

Changed in anybox.recipe.openerp:
importance: Undecided → Critical
status: New → Confirmed
Revision history for this message
Georges Racinet (gracinet) wrote :

I pushed working code for the current master version in the related branch (comments welcome)

This was done from the stable 1.8 branch, but given that Odoo master is now reporting to be 9.0.0 alpha, we may not need to rush this in stable (I did not check the 8.0 branch of Odoo yet).

Changed in anybox.recipe.openerp:
status: Confirmed → In Progress
Revision history for this message
Simon ANDRÉ (sandre) wrote :

Hey,

This bug affect me on a another part of the recipe. The upgrade script. I will try to fix it like you say, and maybe make a merge request.

Thanks a lot

logfile
******
2014-07-11 14:49:28,149 INFO Read package version: 0.4.1-dev from /home/sandre/labo/rhode/project_buildout/VERSION.txt
2014-07-11 14:49:28,149 4822 INFO project_base openerp.upgrade: Read package version: 0.4.1-dev from /home/sandre/labo/rhode/project_buildout/VERSION.txt
Traceback (most recent call last):
  File "bin/upgrade_openerp", line 66, in <module>
    sys.exit(anybox.recipe.openerp.runtime.upgrade.upgrade('/home/sandre/labo/rhode/project_buildout/upgrade.py', 'run', '/home/sandre/labo/rhode/project_buildout/etc/openerp.cfg', '/home/sandre/labo/rhode/project_buildout'))
  File "/home/sandre/labo/rhode/project_buildout/anybox.recipe.openerp/anybox/recipe/openerp/runtime/upgrade.py", line 138, in upgrade
    statuscode = getattr(upgrade_module, upgrade_callable)(session, logger)
  File "/home/sandre/labo/rhode/project_buildout/upgrade.py", line 8, in run
    session.install_modules(modules)
  File "/home/sandre/labo/rhode/project_buildout/anybox.recipe.openerp/anybox/recipe/openerp/runtime/session.py", line 352, in install_modules
    self.update_modules_list()
  File "/home/sandre/labo/rhode/project_buildout/anybox.recipe.openerp/anybox/recipe/openerp/runtime/session.py", line 261, in update_modules_list
    self.registry('ir.module.module').update_list(self.cr, self.uid)
  File "/home/sandre/labo/rhode/project_buildout/parts/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/sandre/labo/rhode/project_buildout/parts/odoo/openerp/addons/base/module/module.py", line 600, in update_list
    known_mods = self.browse(cr, uid, self.search(cr, uid, []))
  File "/home/sandre/labo/rhode/project_buildout/parts/odoo/openerp/api.py", line 204, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/sandre/labo/rhode/project_buildout/parts/odoo/openerp/models.py", line 5043, in browse
    return self._browse(Environment(cr, uid, context or {}), ids)
  File "/home/sandre/labo/rhode/project_buildout/parts/odoo/openerp/api.py", line 666, in __new__
    env, envs = None, cls._local.environments
  File "/home/sandre/.buildout/eggs/Werkzeug-0.8.3-py2.7.egg/werkzeug/local.py", line 70, in __getattr__
    raise AttributeError(name)
AttributeError: environments

Revision history for this message
Simon ANDRÉ (sandre) wrote :

Hey,

I have found the branch related to new odoo api.

It works much better now!

Thanks

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Also just confirming that worked in my console use case too. Thanks.

Revision history for this message
Georges Racinet (gracinet) wrote :

Thanks for the feedback, guys !

Changed in anybox.recipe.openerp:
milestone: none → 1.8.5
status: In Progress → Fix Committed
Changed in anybox.recipe.openerp:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.