Skip to content

Commit

Permalink
Merge 7f79e12 into 0b06ec1
Browse files Browse the repository at this point in the history
  • Loading branch information
tinogis committed Sep 13, 2016
2 parents 0b06ec1 + 7f79e12 commit f926727
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions oopgrade/oopgrade.py
Expand Up @@ -5,6 +5,7 @@

logger = logging.getLogger('openerp.oopgrade')

MODULE_INSTALLED_STATES = ['installed', 'to upgrade', 'to remove']

__all__ = [
'load_data',
Expand All @@ -21,6 +22,7 @@
'add_ir_model_fields',
'install_modules',
'get_foreign_keys'
'module_is_installed',
]


Expand Down Expand Up @@ -407,3 +409,19 @@ def get_foreign_keys(cursor, table):
for fk in cursor.dictfetchall():
res[fk['column_name']] = fk.copy()
return res


def module_is_installed(cursor, module_name):
"""Test if modules is installed.
:param cr: Cursor database
:param module_name: The module name
"""
import pooler

uid = 1
mod_obj = pooler.get_pool(cursor.dbname).get('ir.module.module')
search_params = [('name', 'in', module_name),
('state', 'in', MODULE_INSTALLED_STATES)]
mod_ids = mod_obj.search(cursor, uid, search_params)
return len(mod_ids) > 0

0 comments on commit f926727

Please sign in to comment.