'This method for generating accounts from templates.
:param tax_template_ref: Taxes templates reference for write taxes_id in account_account.
:param acc_template_ref: dictionary with the mappping between the account templates and the real accounts.
:param code_digits: number of digits got from wizard.multi.charts.accounts, this is use for account code.
:param company_id: company_id selected from wizard.multi.charts.accounts.
:returns: return acc_template_ref for reference purpose.
:rtype: dict'

@api.multi
def generate_account(self, tax_template_ref, acc_template_ref, code_digits, company):

    self.ensure_one()
    account_tmpl_obj = self.env['account.account.template']
    acc_template = account_tmpl_obj.search([('nocreate', '!=', True), ('chart_template_id', '=', self.id)], order='id')
    for account_template in acc_template:
        code_main = ((account_template.code and len(account_template.code)) or 0)
        code_acc = (account_template.code or '')
        if ((code_main > 0) and (code_main <= code_digits)):
            code_acc = (str(code_acc) + str(('0' * (code_digits - code_main))))
        vals = self._get_account_vals(company, account_template, code_acc, tax_template_ref)
        new_account = self.create_record_with_xmlid(company, account_template, 'account.account', vals)
        acc_template_ref[account_template.id] = new_account
    return acc_template_ref
