Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
3911 Ansichten

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
    wizard.

    :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,
            }
            journal_data.append(vals)
    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:
                break
            else:
                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

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Juli 25
1075
1
Juli 25
889
0
Feb. 25
1976
2
Sept. 23
11420
0
Mai 21
10102