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.

4

How to check for installed modules from my __init__.py?

By
Nico Bustillos
on 2/8/13, 5:18 PM 2,153 views

Is there some way that I can check if certain module is installed from the __init__.py file (for example if I want to conditionally import one of my .py files depending on whether a specific module is installed, without having to set it as a mandatory dependency in my __openerp__.py).

I see I have no cr cursor to somehow browse it from database, nor do I have the dbname to be able to instantiate my own cursor. I was hoping I could do something like

import openerp.modules as addons
loaded_mods = addons.module.loaded
if 'addon_x' in loaded_mods:
    import addon_x_inheritage

but loaded returns an empty list [].

Is there any workable way to achieve this?

3

Yannick Vaucher

--Yannick Vaucher--
1699
| 5 7 9
Lausanne, Switzerland
--Yannick Vaucher--
Yannick Vaucher
On 2/8/13, 5:54 PM

Create a link module

If your aim to make differents behaviors depending on whether or not a module is installed, you might create a link modules.

From OpenERP 7.0 [1], you can specifiy in your __openerp__.py an option called auto_install

  auto_install     True or False (default: False). If set to ``True``, the
                   module is a link module. It will be installed as soon
                   as all its dependencies are installed.

With this, you should be able to create a module A without all dependancies, and an other link module L which pill patch your module A taking in account the changes made by the module you didn't wanted to set in the module A dependancies.

Otherwise, you may have issues with inheritances processes.


[1] [Module structure](http://doc.openerp.com/trunk/developers/server/03_module_dev_01/)

Ok, this seems the most logical and elegant way to solve this particular problem. However, it would be nice to know if there is a way to specifically "check for installed modules from my __init__.py" for some other scenario.

Poiesis Consulting SRL, Nico Bustillos
on 2/18/13, 11:16 AM

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

0 follower(s)

Stats

Asked: 2/8/13, 5:18 PM
Seen: 2153 times
Last updated: 3/16/15, 8:10 AM