Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if a module is installed or a model is existed in odoo

I want to inherit a form from another custom module without depends but It need to be check if that module is installed or model is existed before inherit it. I researched many docs but not found any solution regards so pls help me how can I do this

like image 339
Phong Vy Avatar asked Dec 19 '22 02:12

Phong Vy


2 Answers

You can know if a module is installed checking the state field in the ir_module_module table.

I hope this help you!

like image 97
Dayana Avatar answered May 16 '23 06:05

Dayana


Check whether the module has been installed, and is in an installed state by querying against ir.module.module:

bokeh = self.env['ir.module.module'].search([('name', '=', 'module_name')])

if not bokeh or bokeh.state != 'installed': 
    raise UserError(_('...'))
like image 40
jackjack82 Avatar answered May 16 '23 07:05

jackjack82