Odoo Help


How to install chart of accounts automatically without inputting data on the Chart of Account initialization wizard?

John Britto
on 11/25/15, 1:28 AM 394 views

Hi Everyone,

I have been trying to automate module installation from a http controller. Installation of module has been succeeded and since accounting module has some wizards to be processed, they are not executed and they are in open state in "ir.actions.todo" table. So I took an example from addons/account/account_pre_install.yml and modified it accordingly. The problem is, the "write" method on ir.actions.todo model is not working and "create" and "execute_simple" methods on "account.installer" model are not working

Here is the whole code for that particular controller.

@http.route('/saas_worker/module', type="json", auth="none")

def check_module(self, fields):

    params = dict(map(operator.itemgetter('name', 'value'), fields))

     super_admin_password = config.get("admin_passwd")

     response_data = {}

         create_attrs = (







db_created = request.session.proxy("db").create_database(*create_attrs)

if db_created:

    db = openerp.sql_db.db_connect(params["db_name"])

    with closing(db.cursor()) as cr:

        registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)

        ir_module = registry['ir.module.module']

        ir_model_data = registry['ir.model.data']

        wizards = registry['ir.actions.todo']

        res_partner = registry['res.partner']

        account_installer = registry['account.installer']

        selected_modules = params["modules"].split(",")

        module_ids = ir_module.search(cr,SUPERUSER_ID,[('name','in',selected_modules)])

        #Install modules automatically


        wizard = wizards.browse(cr,SUPERUSER_ID,self.ref(cr, SUPERUSER_ID,   ir_model_data,'account.account_configuration_installer_todo'))

        if wizard.state=='open':


            ids = ir_module.search(cr, SUPERUSER_ID, [ ('name','=',mod) ], context=None)

            if ids:

                 wizards.write(cr, SUPERUSER_ID, self.ref(cr, SUPERUSER_ID,                     ir_model_data,'account.account_configuration_installer_todo'), {

                    'state': 'done'


                 wizard_id = account_installer.create(cr, SUPERUSER_ID, {

                     'charts': mod


                 account_installer.execute_simple(cr, SUPERUSER_ID, [wizard_id])

                 ir_module.state_update(cr, SUPERUSER_ID, ids,'to install', ['uninstalled'], context=None)

                 response_data["status"] = "ok"

                 response = json.dumps(response_data)

                 return response

def ref(self, cr, uid, registry_obj, external_id):

      return registry_obj.xmlid_to_res_id(cr, uid, external_id, raise_if_not_found=True)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/25/15, 1:28 AM
Seen: 394 times
Last updated: 11/25/15, 1:41 AM