@classmethod
def setUpClass(cls, chart_template_ref=None):
    super().setUpClass()
    if chart_template_ref:
        chart_template = cls.env.ref(chart_template_ref)
    else:
        chart_template = cls.env.ref('l10n_generic_coa.configurable_chart_template', raise_if_not_found=False)
    if (not chart_template):
        cls.tearDownClass()
        cls.skipTest(cls, "Accounting Tests skipped because the user's company has no chart of accounts.")
    user = cls.env['res.users'].create({'name': 'Because I am accountman!', 'login': 'accountman', 'groups_id': [(6, 0, cls.env.user.groups_id.ids), (4, cls.env.ref('account.group_account_user').id)]})
    user.partner_id.email = 'example@example.com'
    cls.env = cls.env(user=user)
    cls.cr = cls.env.cr
    cls.company_data_2 = cls.setup_company_data('company_2_data', chart_template)
    cls.company_data = cls.setup_company_data('company_1_data', chart_template)
    user.write({'company_ids': [(6, 0, (cls.company_data['company'] + cls.company_data_2['company']).ids)], 'company_id': cls.company_data['company'].id})
    cls.currency_data = cls.setup_multi_currency_data()
    cls.tax_sale_a = cls.company_data['default_tax_sale']
    cls.tax_sale_b = cls.company_data['default_tax_sale'].copy()
    cls.tax_purchase_a = cls.company_data['default_tax_purchase']
    cls.tax_purchase_b = cls.company_data['default_tax_purchase'].copy()
    cls.tax_armageddon = cls.setup_armageddon_tax('complex_tax', cls.company_data)
    cls.product_a = cls.env['product.product'].create({'name': 'product_a', 'uom_id': cls.env.ref('uom.product_uom_unit').id, 'lst_price': 1000.0, 'standard_price': 800.0, 'property_account_income_id': cls.company_data['default_account_revenue'].id, 'property_account_expense_id': cls.company_data['default_account_expense'].id, 'taxes_id': [(6, 0, cls.tax_sale_a.ids)], 'supplier_taxes_id': [(6, 0, cls.tax_purchase_a.ids)]})
    cls.product_b = cls.env['product.product'].create({'name': 'product_b', 'uom_id': cls.env.ref('uom.product_uom_dozen').id, 'lst_price': 200.0, 'standard_price': 160.0, 'property_account_income_id': cls.copy_account(cls.company_data['default_account_revenue']).id, 'property_account_expense_id': cls.copy_account(cls.company_data['default_account_expense']).id, 'taxes_id': [(6, 0, (cls.tax_sale_a + cls.tax_sale_b).ids)], 'supplier_taxes_id': [(6, 0, (cls.tax_purchase_a + cls.tax_purchase_b).ids)]})
    cls.fiscal_pos_a = cls.env['account.fiscal.position'].create({'name': 'fiscal_pos_a', 'tax_ids': [(0, None, {'tax_src_id': cls.tax_sale_a.id, 'tax_dest_id': cls.tax_sale_b.id}), (0, None, {'tax_src_id': cls.tax_purchase_a.id, 'tax_dest_id': cls.tax_purchase_b.id})], 'account_ids': [(0, None, {'account_src_id': cls.product_a.property_account_income_id.id, 'account_dest_id': cls.product_b.property_account_income_id.id}), (0, None, {'account_src_id': cls.product_a.property_account_expense_id.id, 'account_dest_id': cls.product_b.property_account_expense_id.id})]})
    cls.pay_terms_a = cls.env.ref('account.account_payment_term_immediate')
    cls.pay_terms_b = cls.env['account.payment.term'].create({'name': '30% Advance End of Following Month', 'note': 'Payment terms: 30% Advance End of Following Month', 'line_ids': [(0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 31, 'option': 'day_following_month'})]})
    cls.partner_a = cls.env['res.partner'].create({'name': 'partner_a', 'property_payment_term_id': cls.pay_terms_a.id, 'property_supplier_payment_term_id': cls.pay_terms_a.id, 'property_account_receivable_id': cls.company_data['default_account_receivable'].id, 'property_account_payable_id': cls.company_data['default_account_payable'].id, 'company_id': False})
    cls.partner_b = cls.env['res.partner'].create({'name': 'partner_b', 'property_payment_term_id': cls.pay_terms_b.id, 'property_supplier_payment_term_id': cls.pay_terms_b.id, 'property_account_position_id': cls.fiscal_pos_a.id, 'property_account_receivable_id': cls.company_data['default_account_receivable'].copy().id, 'property_account_payable_id': cls.company_data['default_account_payable'].copy().id, 'company_id': False})
    cls.cash_rounding_a = cls.env['account.cash.rounding'].create({'name': 'add_invoice_line', 'rounding': 0.05, 'strategy': 'add_invoice_line', 'account_id': cls.copy_account(cls.company_data['default_account_expense']).id, 'rounding_method': 'UP'})
    cls.cash_rounding_b = cls.env['account.cash.rounding'].create({'name': 'biggest_tax', 'rounding': 0.05, 'strategy': 'biggest_tax', 'rounding_method': 'DOWN'})
@classmethod
def setUpClass(cls, chart_template_ref=None):
    super().setUpClass()
    if chart_template_ref:
        chart_template = cls.env.ref(chart_template_ref)
    else:
        chart_template = cls.env.ref('l10n_generic_coa.configurable_chart_template', raise_if_not_found=False)
    if (not chart_template):
        cls.tearDownClass()
        cls.skipTest(cls, "Accounting Tests skipped because the user's company has no chart of accounts.")
    user = cls.env['res.users'].create({'name': 'Because I am accountman!', 'login': 'accountman', 'groups_id': [(6, 0, cls.env.user.groups_id.ids), (4, cls.env.ref('account.group_account_user').id)]})
    user.partner_id.email = 'example@example.com'
    cls.env = cls.env(user=user)
    cls.cr = cls.env.cr
    cls.company_data_2 = cls.setup_company_data('company_2_data', chart_template)
    cls.company_data = cls.setup_company_data('company_1_data', chart_template)
    user.write({'company_ids': [(6, 0, (cls.company_data['company'] + cls.company_data_2['company']).ids)], 'company_id': cls.company_data['company'].id})
    cls.currency_data = cls.setup_multi_currency_data()
    cls.tax_sale_a = cls.company_data['default_tax_sale']
    cls.tax_sale_b = cls.company_data['default_tax_sale'].copy()
    cls.tax_purchase_a = cls.company_data['default_tax_purchase']
    cls.tax_purchase_b = cls.company_data['default_tax_purchase'].copy()
    cls.tax_armageddon = cls.setup_armageddon_tax('complex_tax', cls.company_data)
    cls.product_a = cls.env['product.product'].create({'name': 'product_a', 'uom_id': cls.env.ref('uom.product_uom_unit').id, 'lst_price': 1000.0, 'standard_price': 800.0, 'property_account_income_id': cls.company_data['default_account_revenue'].id, 'property_account_expense_id': cls.company_data['default_account_expense'].id, 'taxes_id': [(6, 0, cls.tax_sale_a.ids)], 'supplier_taxes_id': [(6, 0, cls.tax_purchase_a.ids)]})
    cls.product_b = cls.env['product.product'].create({'name': 'product_b', 'uom_id': cls.env.ref('uom.product_uom_dozen').id, 'lst_price': 200.0, 'standard_price': 160.0, 'property_account_income_id': cls.copy_account(cls.company_data['default_account_revenue']).id, 'property_account_expense_id': cls.copy_account(cls.company_data['default_account_expense']).id, 'taxes_id': [(6, 0, (cls.tax_sale_a + cls.tax_sale_b).ids)], 'supplier_taxes_id': [(6, 0, (cls.tax_purchase_a + cls.tax_purchase_b).ids)]})
    cls.fiscal_pos_a = cls.env['account.fiscal.position'].create({'name': 'fiscal_pos_a', 'tax_ids': [(0, None, {'tax_src_id': cls.tax_sale_a.id, 'tax_dest_id': cls.tax_sale_b.id}), (0, None, {'tax_src_id': cls.tax_purchase_a.id, 'tax_dest_id': cls.tax_purchase_b.id})], 'account_ids': [(0, None, {'account_src_id': cls.product_a.property_account_income_id.id, 'account_dest_id': cls.product_b.property_account_income_id.id}), (0, None, {'account_src_id': cls.product_a.property_account_expense_id.id, 'account_dest_id': cls.product_b.property_account_expense_id.id})]})
    cls.pay_terms_a = cls.env.ref('account.account_payment_term_immediate')
    cls.pay_terms_b = cls.env['account.payment.term'].create({'name': '30% Advance End of Following Month', 'note': 'Payment terms: 30% Advance End of Following Month', 'line_ids': [(0, 0, {'value': 'percent', 'value_amount': 30.0, 'sequence': 400, 'days': 0, 'option': 'day_after_invoice_date'}), (0, 0, {'value': 'balance', 'value_amount': 0.0, 'sequence': 500, 'days': 31, 'option': 'day_following_month'})]})
    cls.partner_a = cls.env['res.partner'].create({'name': 'partner_a', 'property_payment_term_id': cls.pay_terms_a.id, 'property_supplier_payment_term_id': cls.pay_terms_a.id, 'property_account_receivable_id': cls.company_data['default_account_receivable'].id, 'property_account_payable_id': cls.company_data['default_account_payable'].id, 'company_id': False})
    cls.partner_b = cls.env['res.partner'].create({'name': 'partner_b', 'property_payment_term_id': cls.pay_terms_b.id, 'property_supplier_payment_term_id': cls.pay_terms_b.id, 'property_account_position_id': cls.fiscal_pos_a.id, 'property_account_receivable_id': cls.company_data['default_account_receivable'].copy().id, 'property_account_payable_id': cls.company_data['default_account_payable'].copy().id, 'company_id': False})
    cls.cash_rounding_a = cls.env['account.cash.rounding'].create({'name': 'add_invoice_line', 'rounding': 0.05, 'strategy': 'add_invoice_line', 'account_id': cls.copy_account(cls.company_data['default_account_expense']).id, 'rounding_method': 'UP'})
    cls.cash_rounding_b = cls.env['account.cash.rounding'].create({'name': 'biggest_tax', 'rounding': 0.05, 'strategy': 'biggest_tax', 'rounding_method': 'DOWN'})