Reading list Switch to dark mode

    Install Module Programmatically in Odoo

    Updated 17 May 2017

    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 ?
    Find out 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.

     

    . . .

    Leave a Comment

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


    2 comments

  • Bojan Nišević
    • Ashish Singh (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content