@classmethod
def setup_company_data(cls, company_name, chart_template, **kwargs):
    ' Create a new company having the name passed as parameter.\n        A chart of accounts will be installed to this company: the same as the current company one.\n        The current user will get access to this company.\n\n        :param company_name: The name of the company.\n        :return: A dictionary will be returned containing all relevant accounting data for testing.\n        '

    def search_account(company, chart_template, field_name, domain):
        template_code = chart_template[field_name].code
        domain = ([('company_id', '=', company.id)] + domain)
        account = None
        if template_code:
            account = cls.env['account.account'].search((domain + [('code', '=like', (template_code + '%'))]), limit=1)
        if (not account):
            account = cls.env['account.account'].search(domain, limit=1)
        return account
    currency = chart_template.currency_id
    company = cls.env['res.company'].create({'name': company_name, 'currency_id': currency.id, **kwargs})
    cls.env.user.company_ids |= company
    chart_template.try_loading(company=company)
    company.write({'currency_id': kwargs.get('currency_id', currency.id)})
    return {'company': company, 'currency': company.currency_id, 'default_account_revenue': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_revenue').id)], limit=1), 'default_account_expense': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_expenses').id)], limit=1), 'default_account_receivable': search_account(company, chart_template, 'property_account_receivable_id', [('user_type_id.type', '=', 'receivable')]), 'default_account_payable': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id.type', '=', 'payable')], limit=1), 'default_account_assets': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id)], limit=1), 'default_account_tax_sale': company.account_sale_tax_id.mapped('invoice_repartition_line_ids.account_id'), 'default_account_tax_purchase': company.account_purchase_tax_id.mapped('invoice_repartition_line_ids.account_id'), 'default_journal_misc': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'general')], limit=1), 'default_journal_sale': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'sale')], limit=1), 'default_journal_purchase': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'purchase')], limit=1), 'default_journal_bank': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'bank')], limit=1), 'default_journal_cash': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'cash')], limit=1), 'default_tax_sale': company.account_sale_tax_id, 'default_tax_purchase': company.account_purchase_tax_id}
Create a new company having the name passed as parameter.
A chart of accounts will be installed to this company: the same as the current company one.
The current user will get access to this company.

:param company_name: The name of the company.
:return: A dictionary will be returned containing all relevant accounting data for testing.
@classmethod
def setup_company_data(cls, company_name, chart_template, **kwargs):
    ' Create a new company having the name passed as parameter.\n        A chart of accounts will be installed to this company: the same as the current company one.\n        The current user will get access to this company.\n\n        :param company_name: The name of the company.\n        :return: A dictionary will be returned containing all relevant accounting data for testing.\n        '

    def search_account(company, chart_template, field_name, domain):
        template_code = chart_template[field_name].code
        domain = ([('company_id', '=', company.id)] + domain)
        account = None
        if template_code:
            account = cls.env['account.account'].search((domain + [('code', '=like', (template_code + '%'))]), limit=1)
        if (not account):
            account = cls.env['account.account'].search(domain, limit=1)
        return account
    currency = chart_template.currency_id
    company = cls.env['res.company'].create({'name': company_name, 'currency_id': currency.id, **kwargs})
    cls.env.user.company_ids |= company
    chart_template.try_loading(company=company)
    company.write({'currency_id': kwargs.get('currency_id', currency.id)})
    return {'company': company, 'currency': company.currency_id, 'default_account_revenue': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_revenue').id)], limit=1), 'default_account_expense': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_expenses').id)], limit=1), 'default_account_receivable': search_account(company, chart_template, 'property_account_receivable_id', [('user_type_id.type', '=', 'receivable')]), 'default_account_payable': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id.type', '=', 'payable')], limit=1), 'default_account_assets': cls.env['account.account'].search([('company_id', '=', company.id), ('user_type_id', '=', cls.env.ref('account.data_account_type_current_assets').id)], limit=1), 'default_account_tax_sale': company.account_sale_tax_id.mapped('invoice_repartition_line_ids.account_id'), 'default_account_tax_purchase': company.account_purchase_tax_id.mapped('invoice_repartition_line_ids.account_id'), 'default_journal_misc': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'general')], limit=1), 'default_journal_sale': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'sale')], limit=1), 'default_journal_purchase': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'purchase')], limit=1), 'default_journal_bank': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'bank')], limit=1), 'default_journal_cash': cls.env['account.journal'].search([('company_id', '=', company.id), ('type', '=', 'cash')], limit=1), 'default_tax_sale': company.account_sale_tax_id, 'default_tax_purchase': company.account_purchase_tax_id}