Read More
Read More
Menu Close

    Install Module Programmatically in Odoo

    If you want to install Odoo modules without using user interface or via terminal then this blog will help you to install module programmatically.

    There have multiple ways to install module in Odoo. You can install module via commands or programmatically as well. Programmatically you can install module using below ways.

    • Install module during database creation.
    • Install module by clicking on button or any action.

    Install module on database creation

    In order to install module during database creation simply add below tag in “__manifest__.py” file or if Odoo version older than 10.0 then add below tag inside “__openerp__.py“.

    {
    'auto_install': True,
    }

    Make this tag “true” in order to install module during database creation.

    Install module by clicking on button or any action

    In order to install module during any action or button click use below code.

    Searching for an experienced
    Odoo Company ?
    Read More
    irModuleObj = self.env['ir.module.module']
    irModuleObj.update_list()
    moduleIds = irModuleObj.search(
                                   [
                                    ('state', '!=', 'installed'),
                                    ('name', '=', 'technical name of module')
                                   ]
                                  )
    if moduleIds:
       moduleIds[0].button_immediate_install()

    Above code will help to install module programmatically.

    • update_list(): This method helps to update module list reason why this method should use before installation because if any new module is placed on server then without running this method that module will not come on module list.
    • moduleIds: In this line we check module is currently installed or not.
    • button_immediate_install(): This method helps to install module of given id.

     

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    2 comments

  • Bojan Nišević
    Thanks for the info. But only thing missing here is for the second part where irModuleObj can be used? In which class? “self” will not work like that everywhere?
    • Ashish Singh (Moderator)
      Hi, Bojan

      Here “irModuleObj” contains the instance of “ir.module.module”.
      irModuleObj = self.env[‘ir.module.module’]

      Thanks,
      Webkul Team

  • Back to Top

    Table of Content