Odoo Help


The Performance problem in account module

on 7/10/13, 4:20 AM 1,196 views

In the below method in account module, while executing the sentence:

default_account_id = obj_acc.create(cr, uid, vals, context=context)

It will take more than 10 seconds to finish which is very weird. Is there any thing we can do to improve the performance here?

def _create_bank_journals_from_o2m(self, cr, uid, obj_wizard, company_id, acc_template_ref, context=None):
    This function creates bank journals and its accounts for each line encoded in the field bank_accounts_id of the

    :param obj_wizard: the current wizard that generates the COA from the templates.
    :param company_id: the id of the company for which the wizard is running.
    :param acc_template_ref: the dictionary containing the mapping between the ids of account templates and the ids
        of the accounts that have been generated from them.
    :return: True
    obj_acc = self.pool.get('account.account')
    obj_journal = self.pool.get('account.journal')
    code_digits = obj_wizard.code_digits

    # Build a list with all the data to process
    journal_data = []
    if obj_wizard.bank_accounts_id:
        for acc in obj_wizard.bank_accounts_id:
            vals = {
                'acc_name': acc.acc_name,
                'account_type': acc.account_type,
                'currency_id': acc.currency_id.id,
    ref_acc_bank = obj_wizard.chart_template_id.bank_account_view_id
    if journal_data and not ref_acc_bank.code:
        raise osv.except_osv(_('Configuration Error!'), _('You have to set a code for the bank account defined on the selected chart of accounts.'))

    current_num = 1
    for line in journal_data:
        # Seek the next available number for the account code
        while True:
            new_code = str(ref_acc_bank.code.ljust(code_digits-len(str(current_num)), '0')) + str(current_num)
            ids = obj_acc.search(cr, uid, [('code', '=', new_code), ('company_id', '=', company_id)])
            if not ids:
                current_num += 1
        # Create the default debit/credit accounts for this bank journal
        vals = self._prepare_bank_account(cr, uid, line, new_code, acc_template_ref, ref_acc_bank, company_id, context=context)
        **default_account_id  = obj_acc.create(cr, uid, vals, context=context)**

        #create the bank journal
        vals_journal = self._prepare_bank_journal(cr, uid, line, current_num, default_account_id, company_id, context=context)
        obj_journal.create(cr, uid, vals_journal)
        current_num += 1
return True


Regards Sage

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: 7/10/13, 4:20 AM
Seen: 1196 times
Last updated: 3/16/15, 8:10 AM