Community mailing list archives

Re: Dynamic / conditional module dependencies

Mohamed Magdy
- 06/29/2016 15:57:40
Hi Mohamed,

You can do this by checking if the module if installed or not, for example:

def _cehck_installed(self, module_name):
     module = self.env['ir.module.module].browse([('name', '=', module_name )]
    if module.state == 'installed':
       return True
   return False

In your code:
def foo(self):
      if self._check_installed('sale'):
         # Do something
          # Do something else

Please note: This code is not accurate and not tested. it is just for explaining the idea.

Thank you :) 

On Wed, Jun 29, 2016 at 9:42 PM Mohamed M. Hagag <> wrote:


In many cases we want to build a module that affects for ex. sale, product and POS.

but we don't want the functions that affect POS to be executed in case that POS is not installed.

the way we can build a general module that doesn't depend on POS but affects it if only installed.

How can we achieve this behaviour in odoo 8 or 9 without building module for sale and another for POS ?


Post to:

Best Regards,

Mohamed Magdy
Odoo Technical Team Leader
Mob 1: +201114347478
Mob 2: +201095179215