There is some non-obvious issue with external dependency in modules, which I want to say.


Let you need to use some python lib, which is not available in system by default and should be installed manually.

So you just make import:

from pandas import DataFrame

And maybe you mention required dependence in module's description. Very simple, right? But…


The case could crash odoo completely.

This is scenario when it could happen:

  • User is not going to use your module with external dependency, but your module available in Local Modules. E.g. if have a lot of modules in your git repository and user just makes git clone and add path to repo to addons-path.
  • User's system doesn't have required dependency
  • Your module has static/ folder, e.g. to place icon.png file.

Then right after restarting server, user would get error:

2015-07-05 04:57:15,078 5760 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/share/pyshared/werkzeug/", line 159, in run_wsgi
  File "/usr/share/pyshared/werkzeug/", line 146, in execute
    application_iter = app(environ, start_response)
  File "/mnt/files/src/odoo/openerp/service/", line 281, in app
    return, s)
  File "/mnt/files/src/odoo/openerp/service/", line 216, in application
    return application_unproxied(environ, start_response)
  File "/mnt/files/src/odoo/openerp/service/", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/mnt/files/src/odoo/openerp/", line 1244, in __call__
  File "/mnt/files/src/odoo/openerp/", line 1263, in load_addons
    m = __import__('openerp.addons.' + module)
  File "/mnt/files/src/odoo/openerp/modules/", line 77, in load_module
    mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
  File "/mnt/files/git/addons-yelizariev/import_custom/", line 1, in <module>
    import wizard
  File "/mnt/files/git/addons-yelizariev/import_custom/wizard/", line 1, in <module>
    import upload
  File "/mnt/files/git/addons-yelizariev/import_custom/wizard/", line 14, in <module>
    from pandas import DataFrame
ImportError: No module named pandas


Whenever you use external dependency, put your import code in try block

    from pandas import DataFrame
except ImportError:

and add external_dependencies to module's manifest:

"external_dependencies": {
    'python': ['pandas']

It will check dependencies before installing and will not raise ImportError if user doesn't use module.