Community mailing list archives

community@mail.odoo.com

Re: Dynamic / conditional module dependencies

by
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
       else:
          # 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 <mohamedhagag1981@gmail.com> wrote:

Dears,


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 ?


Regards,

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

--
Best Regards,

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