Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX import error for odoo v10 #12

Open
wants to merge 1 commit into
base: fix_for_odoo10
Choose a base branch
from
Open

FIX import error for odoo v10 #12

wants to merge 1 commit into from

Conversation

PieterPaulussen
Copy link

Mixup in odoo import
Shorter import statement
if Odoo is not found, Openerp should be imported as Odoo

Mixup in odoo import
Copy link
Collaborator

@petrus-v petrus-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make sure this is not a side effect on my environment. If not maybe trying to import openerp as odoo first should be work!

I'll test and let you know!

from odoo.cli import server as startup
except ImportError:
from .backports.cli import server as startup
from odoo.tools import config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've test something similar, looks pretty much cleaner however this code result to make integration test failing on v8

pverkest@petrus-v:~/tmp/aro_8$ bin/nosetests -d aro8 -- -s -v ../aro/tests_with_odoo/
Traceback (most recent call last):
  File "bin/nosetests", line 60, in <module>
    from anybox.recipe.odoo.runtime.session import Session
  File "/home/pverkest/tmp/aro/anybox/recipe/odoo/runtime/session.py", line 21, in <module>
    from odoo.tools import config
ImportError: No module named tools

This sounds strange to me, it's like import odoo do not raise ImportError exceptions... I'll go in deep on that...

Copy link
Collaborator

@petrus-v petrus-v Jan 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python appear to not be able to load python module from aliases:

>>> from xml.dom import domreg
>>> domreg
<module 'xml.dom.domreg' from '/usr/lib/python2.7/xml/dom/domreg.pyc'>
>>> import xml as tmp
>>> from tmp.dom import domreg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named tmp.dom
>>> 

I've test that which works in our case

try:
    import openerp as odoo
except ImportError:
    try:
        import odoo
    except ImportError:
        warnings.warn("This must be imported with a buildout odoo recipe "
                      "driven sys.path", RuntimeWarning)
try:
    startup = odoo.cli.server
except ImportError:
    from .backports.cli import server as startup
config = odoo.tools.config
SUPERUSER_ID = odoo.SUPERUSER_ID
parse_version = odoo.tools.parse_version

@PieterPaulussen what do you think about?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants