From f44fbdb83310b9e96166c9a75971530e50306b4a Mon Sep 17 00:00:00 2001 From: Yannick Tivisse <yti@odoo.com> Date: Thu, 7 Nov 2019 12:01:21 +0000 Subject: [PATCH] [IMP] account: Clean common tests classes --- addons/account/tests/__init__.py | 1 - addons/account/tests/account_minimal_test.py | 294 ----- addons/account/tests/account_test_classes.py | 49 - addons/account/tests/account_test_no_chart.py | 130 --- .../account/tests/account_test_savepoint.py | 209 ---- addons/account/tests/account_test_users.py | 36 - addons/account/tests/common.py | 1031 +++++++++++++++++ addons/account/tests/invoice_test_common.py | 147 --- .../tests/test_account_bank_statement.py | 4 +- .../account/tests/test_account_fiscal_year.py | 4 +- .../tests/test_account_invoice_report.py | 4 +- .../tests/test_account_journal_dashboard.py | 4 +- .../account/tests/test_account_move_entry.py | 4 +- .../tests/test_account_move_in_invoice.py | 4 +- .../tests/test_account_move_in_refund.py | 4 +- .../tests/test_account_move_out_invoice.py | 4 +- .../tests/test_account_move_out_refund.py | 4 +- .../tests/test_account_move_rounding.py | 4 +- .../test_bank_statement_reconciliation.py | 4 +- .../tests/test_control_journal_account.py | 4 +- addons/account/tests/test_invoice_taxes.py | 4 +- addons/account/tests/test_payment.py | 4 +- addons/account/tests/test_reconciliation.py | 250 +--- .../test_reconciliation_matching_rules.py | 4 +- addons/account/tests/test_search.py | 4 +- addons/account/tests/test_settings.py | 4 +- addons/account/tests/test_tax.py | 4 +- .../tests/test_print_check.py | 4 +- .../tests/test_delivery_stock_move.py | 4 +- addons/hr_expense/tests/common.py | 4 +- addons/l10n_ch/tests/test_l10n_ch_isr.py | 4 +- addons/membership/tests/common.py | 4 +- addons/payment/tests/common.py | 4 +- addons/point_of_sale/tests/common.py | 6 +- .../tests/test_pos_products_with_tax.py | 2 +- .../tests/test_product_margin.py | 4 +- .../tests/test_purchase_order_report.py | 4 +- ...st_anglo_saxon_valuation_reconciliation.py | 4 +- .../tests/test_average_price.py | 4 +- .../purchase_stock/tests/test_fifo_price.py | 4 +- .../purchase_stock/tests/test_fifo_returns.py | 4 +- .../tests/test_purchase_order.py | 4 +- .../tests/test_stockvaluation.py | 4 +- addons/repair/tests/test_repair.py | 4 +- addons/sale/tests/test_sale_common.py | 10 +- addons/sale/tests/test_sale_transaction.py | 4 +- addons/sale_mrp/tests/test_sale_mrp_flow.py | 4 +- ...st_anglo_saxon_valuation_reconciliation.py | 4 +- .../tests/test_pingen_send.py | 4 +- ...tock_account_minimal_test.py => common.py} | 6 +- ...o_saxon_valuation_reconciliation_common.py | 6 +- .../tests/test_lifo_price.py | 4 +- .../tests/test_stockvaluation.py | 4 +- addons/stock_landed_costs/tests/common.py | 4 +- .../tests/test_stock_landed_costs.py | 4 +- .../tests/test_stock_landed_costs_rounding.py | 4 +- .../tests/test_stockvaluationlayer.py | 4 +- 57 files changed, 1138 insertions(+), 1211 deletions(-) delete mode 100644 addons/account/tests/account_minimal_test.py delete mode 100644 addons/account/tests/account_test_classes.py delete mode 100644 addons/account/tests/account_test_no_chart.py delete mode 100644 addons/account/tests/account_test_savepoint.py delete mode 100644 addons/account/tests/account_test_users.py create mode 100644 addons/account/tests/common.py delete mode 100644 addons/account/tests/invoice_test_common.py rename addons/stock_account/tests/{stock_account_minimal_test.py => common.py} (83%) diff --git a/addons/account/tests/__init__.py b/addons/account/tests/__init__.py index 7bf7eabf1516..004d914db65e 100644 --- a/addons/account/tests/__init__.py +++ b/addons/account/tests/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from . import account_minimal_test from . import test_account_move_out_invoice from . import test_account_move_out_refund from . import test_account_move_in_invoice diff --git a/addons/account/tests/account_minimal_test.py b/addons/account/tests/account_minimal_test.py deleted file mode 100644 index daaaaa35652a..000000000000 --- a/addons/account/tests/account_minimal_test.py +++ /dev/null @@ -1,294 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo.tests.common import SavepointCase - - -class AccountMinimalTest(SavepointCase): - """ This should be loaded for non python tests in other modules that require - accounting test data but that don't depend on any localization""" - - @classmethod - def setUpClass(cls): - super(AccountMinimalTest, cls).setUpClass() - cls.create_accounting_minimal_data() - - @classmethod - def create_accounting_minimal_data(cls): - cls.company = cls.env.company - cls.company.bank_account_code_prefix = 'X1100' - - # Chart of Accounts - - # Account Tags - cls.demo_capital_account = cls.env['account.account.tag'].create({'name': 'Demo Capital Account'}) - cls.demo_stock_account = cls.env['account.account.tag'].create({'name': 'Demo Stock Account'}) - cls.demo_sale_of_land_account = cls.env['account.account.tag'].create({'name': 'Demo Sale of Land Account'}) - cls.demo_ceo_wages_account = cls.env['account.account.tag'].create({'name': 'Demo CEO Wages Account'}) - cls.demo_office_furniture_account = cls.env['account.account.tag'].create({'name': 'Office Furniture'}) - - # Balance Sheet - cls.xfa = cls.env['account.account'].create({ - 'code': 'X1000', - 'name': 'Fixed Assets - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id, - }) - cls.cas = cls.env['account.account'].create({ - 'code': 'X1010', - 'name': 'Current Assets - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - }) - cls.stk = cls.env['account.account'].create({ - 'code': 'X1011', - 'name': 'Purchased Stocks - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - 'tag_ids': [(6, 0, [cls.demo_stock_account.id])] - }) - cls.a_recv = cls.env['account.account'].create({ - 'code': 'X1012', - 'name': 'Debtors - (test)', - 'reconcile': True, - 'user_type_id': cls.env.ref('account.data_account_type_receivable').id, - }) - cls.ova = cls.env['account.account'].create({ - 'code': 'X1013', - 'name': 'VAT Paid- (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - }) - cls.bnk = cls.env['account.account'].create({ - 'code': 'X1014', - 'name': 'Bank Current Account - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, - }) - cls.cash = cls.env['account.account'].create({ - 'code': 'X1015', - 'name': 'Cash - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, - }) - cls.o_income = cls.env['account.account'].create({ - 'code': 'X1016', - 'name': 'Opening Income - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_other_income').id, - }) - cls.usd_bnk = cls.env['account.account'].create({ - 'code': 'X1017', - 'name': 'USD Bank Account - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, - 'currency_id': cls.env.ref('base.USD').id, - }) - cls.transfer_account = cls.env['account.account'].create({ - 'code': 'X1019', - 'name': 'Internal Transfert Account - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - 'reconcile': True, - }) - cls.ncas = cls.env['account.account'].create({ - 'code': 'X1020', - 'name': 'Non-current Assets - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_non_current_assets').id, - }) - cls.prepayements = cls.env['account.account'].create({ - 'code': 'X1030', - 'name': 'Prepayments - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_prepayments').id, - }) - cls.current_liabilities = cls.env['account.account'].create({ - 'code': 'X1110', - 'name': 'Current Liabilities - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, - }) - cls.a_pay = cls.env['account.account'].create({ - 'code': 'X1111', - 'name': 'Creditors - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_payable').id, - 'reconcile': True, - }) - cls.iva = cls.env['account.account'].create({ - 'code': 'X1112', - 'name': 'VAT Received - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, - }) - cls.rsa = cls.env['account.account'].create({ - 'code': 'X1113', - 'name': 'Reserve and Profit/Loss - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, - }) - cls.cas = cls.env['account.account'].create({ - 'code': 'X1120', - 'name': 'Non-current Liabilities - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_non_current_liabilities').id, - }) - cls.o_expense = cls.env['account.account'].create({ - 'code': 'X1114', - 'name': 'Opening Expense - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - }) - - # Profit and Loss - cls.income_fx_income = cls.env['account.account'].create({ - 'code': 'X2010', - 'name': 'Foreign Exchange Gain - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, - 'reconcile': False, - }) - cls.a_sale = cls.env['account.account'].create({ - 'code': 'X2020', - 'name': 'Product Sales - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], - }) - cls.a_sale_invest = cls.env['account.account'].create({ - 'code': 'X2021', - 'name': 'Sale of Lands - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])], - }) - cls.a_sale_finance = cls.env['account.account'].create({ - 'code': 'X2022', - 'name': 'Bank Accounts Interests - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])], - }) - cls.a_sale_finance = cls.env['account.account'].create({ - 'code': 'X2030', - 'name': 'Cost of Goods Sold - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_direct_costs').id, - }) - cls.income_fx_expense = cls.env['account.account'].create({ - 'code': 'X2110', - 'name': 'Foreign Exchange Loss - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - 'reconcile': False, - }) - cls.a_expense = cls.env['account.account'].create({ - 'code': 'X2120', - 'name': 'Expenses - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], - }) - cls.a_salary_expense = cls.env['account.account'].create({ - 'code': 'X2121', - 'name': 'Salary Expenses - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], - }) - cls.a_expense_invest = cls.env['account.account'].create({ - 'code': 'X2122', - 'name': 'Purchase of Equipments - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])], - }) - cls.a_expense_finance = cls.env['account.account'].create({ - 'code': 'X2123', - 'name': 'Bank Fees - (test)', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])], - }) - cls.a_capital = cls.env['account.account'].create({ - 'code': 'X3001', - 'name': 'Capital', - 'user_type_id': cls.env.ref('account.data_account_type_equity').id, - }) - cls.a_dividends = cls.env['account.account'].create({ - 'code': 'X3002', - 'name': 'Dividends', - 'user_type_id': cls.env.ref('account.data_account_type_equity').id, - }) - - # Properties: Product income and expense accounts, default parameters - cls.env['ir.property'].create([{ - 'name': 'property_account_receivable_id', - 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_receivable_id')], limit=1).id, - 'value': 'account.account,%s' % (cls.a_recv.id), - 'company_id': cls.company.id, - }, { - 'name': 'property_account_payable_id', - 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_payable_id')], limit=1).id, - 'value': 'account.account,%s' % (cls.a_pay.id), - 'company_id': cls.company.id, - }, { - 'name': 'property_account_position_id', - 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_position_id')], limit=1).id, - 'value': False, - 'company_id': cls.company.id, - }, { - 'name': 'property_account_expense_categ_id', - 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_expense_categ_id')], limit=1).id, - 'value': 'account.account,%s' % (cls.a_expense.id), - 'company_id': cls.company.id, - }, { - 'name': 'property_account_income_categ_id', - 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_income_categ_id')], limit=1).id, - 'value': 'account.account,%s' % (cls.a_sale.id), - 'company_id': cls.company.id, - }]) - - # Bank Accounts - cls.bank_account = cls.env['res.partner.bank'].create({ - 'acc_number': '987654321', - 'bank_name': 'Bank', - 'partner_id': cls.company.partner_id.id, - }) - cls.bank_account_usd = cls.env['res.partner.bank'].create({ - 'acc_number': '123456789', - 'bank_name': 'Bank US', - 'partner_id': cls.company.partner_id.id, - }) - - # Account Journal - cls.sales_journal = cls.env['account.journal'].create({ - 'name': 'Customer Invoices - Test', - 'code': 'TINV', - 'type': 'sale', - 'default_credit_account_id': cls.a_sale.id, - 'default_debit_account_id': cls.a_sale.id, - 'refund_sequence': True, - }) - cls.expenses_journal = cls.env['account.journal'].create({ - 'name': 'Vendor Bills - Test', - 'code': 'TEXJ', - 'type': 'purchase', - 'default_credit_account_id': cls.a_expense.id, - 'default_debit_account_id': cls.a_expense.id, - 'refund_sequence': True, - }) - cls.bank_journal = cls.env['account.journal'].create({ - 'name': 'Bank - Test', - 'code': 'TBNK', - 'type': 'bank', - 'default_credit_account_id': cls.bnk.id, - 'default_debit_account_id': cls.bnk.id, - }) - cls.cash_journal = cls.env['account.journal'].create({ - 'name': 'Cash - Test', - 'code': 'TCSH', - 'type': 'cash', - 'profit_account_id': cls.rsa.id, - 'loss_account_id': cls.rsa.id, - 'default_credit_account_id': cls.cash.id, - 'default_debit_account_id': cls.cash.id, - }) - cls.miscellaneous_journal = cls.env['account.journal'].create({ - 'name': 'Miscellaneous - Test', - 'code': 'TMIS', - 'type': 'general', - 'show_on_dashboard': False, - }) - cls.currency_diff_journal = cls.env['account.journal'].create({ - 'name': 'Currency Difference - Test', - 'code': 'CUR', - 'type': 'general', - 'default_credit_account_id': cls.income_fx_expense.id, - 'default_debit_account_id': cls.income_fx_income.id, - 'show_on_dashboard': False, - }) - cls.bank_journal_usd = cls.env['account.journal'].create({ - 'name': 'USD Bank - Test', - 'code': 'TUBK', - 'type': 'bank', - 'default_credit_account_id': cls.usd_bnk.id, - 'default_debit_account_id': cls.usd_bnk.id, - 'bank_account_id': cls.bank_account_usd.id, - }) - - cls.company.currency_exchange_journal_id = cls.currency_diff_journal.id diff --git a/addons/account/tests/account_test_classes.py b/addons/account/tests/account_test_classes.py deleted file mode 100644 index 8db3804321f2..000000000000 --- a/addons/account/tests/account_test_classes.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- - -import logging -_logger = logging.getLogger(__name__) - -from odoo.tests.common import HttpCase, tagged -from odoo.addons.account.tests.account_minimal_test import AccountMinimalTest - -class AccountingTestCase(AccountMinimalTest): - """ This class extends the base SavePoint Case, in order to test the - accounting with localization setups. It is configured to run the tests after - the installation of all modules, and will SKIP TESTS if it cannot find an already - configured accounting (which means no localization module has been installed). - """ - - @classmethod - def setUpClass(cls): - super(AccountingTestCase, cls).setUpClass() - domain = [('company_id', '=', cls.env.company.id)] - if not cls.env['account.account'].search_count(domain): - _logger.warning('Test skipped because there is no chart of account defined ...') - cls.skipTest(cls, "No Chart of account found") - - def ensure_account_property(self, property_name): - '''Ensure the ir.property targeting an account.account passed as parameter exists. - In case it's not: create it with a random account. This is useful when testing with - partially defined localization (missing stock properties for example) - - :param property_name: The name of the property. - ''' - company_id = self.env.company - field_id = self.env['ir.model.fields'].search( - [('model', '=', 'product.template'), ('name', '=', property_name)], limit=1) - property_id = self.env['ir.property'].search([ - ('company_id', '=', company_id.id), - ('name', '=', property_name), - ('res_id', '=', None), - ('fields_id', '=', field_id.id)], limit=1) - account_id = self.env['account.account'].search([('company_id', '=', company_id.id)], limit=1) - value_reference = 'account.account,%d' % account_id.id - if property_id and not property_id.value_reference: - property_id.value_reference = value_reference - else: - self.env['ir.property'].create({ - 'name': property_name, - 'company_id': company_id.id, - 'fields_id': field_id.id, - 'value_reference': value_reference, - }) diff --git a/addons/account/tests/account_test_no_chart.py b/addons/account/tests/account_test_no_chart.py deleted file mode 100644 index a42bc2755dbe..000000000000 --- a/addons/account/tests/account_test_no_chart.py +++ /dev/null @@ -1,130 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo.tests.common import SavepointCase, HttpCase, tagged -from odoo.addons.base.tests.common import SavepointCaseWithUserDemo - -class TestAccountNoChartCommon(SavepointCaseWithUserDemo): - """ Some tests required to be executed at module installation, and not 'post install', like moslty - of accounting tests, since a chart of account is required - This test setup class provides data for test suite to make business flow working without a chart - of account installed. The class provide some helpers methods to create particular document types. Each - test suite extending this method can call thoses method to set up their testing environment in their - own `setUpClass` method. - """ - - @classmethod - def setUpClass(cls): - """ This method set up the minimal requried part of chart of account """ - super(TestAccountNoChartCommon, cls).setUpClass() - # To speed up test, create object without mail tracking - context_no_mail = {'no_reset_password': True, 'mail_create_nosubscribe': True, 'mail_create_nolog': True} - - # Create base account to simulate a chart of account - user_type_payable = cls.env.ref('account.data_account_type_payable') - cls.account_payable = cls.env['account.account'].create({ - 'code': 'NC1110', - 'name': 'Test Payable Account', - 'user_type_id': user_type_payable.id, - 'reconcile': True - }) - user_type_receivable = cls.env.ref('account.data_account_type_receivable') - cls.account_receivable = cls.env['account.account'].create({ - 'code': 'NC1111', - 'name': 'Test Receivable Account', - 'user_type_id': user_type_receivable.id, - 'reconcile': True - }) - - # Create a customer - Partner = cls.env['res.partner'].with_context(context_no_mail) - cls.partner_customer_usd = Partner.create({ - 'name': 'Customer from the North', - 'email': 'customer.usd@north.com', - 'property_account_payable_id': cls.account_payable.id, - 'property_account_receivable_id': cls.account_receivable.id, - 'company_id': cls.env.ref('base.main_company').id - }) - - cls.sale_journal0 = cls.env['account.journal'].create({ - 'name': 'Sale Journal', - 'type': 'sale', - 'code': 'SJT0', - }) - - @classmethod - def setUpAdditionalAccounts(cls): - """ Set up some addionnal accounts: expenses, revenue, ... """ - user_type_income = cls.env.ref('account.data_account_type_direct_costs') - cls.account_income = cls.env['account.account'].create({ - 'code': 'NC1112', 'name': - 'Sale - Test Account', - 'user_type_id': user_type_income.id - }) - user_type_expense = cls.env.ref('account.data_account_type_expenses') - cls.account_expense = cls.env['account.account'].create({ - 'code': 'NC1113', - 'name': 'HR Expense - Test Purchase Account', - 'user_type_id': user_type_expense.id - }) - user_type_revenue = cls.env.ref('account.data_account_type_revenue') - cls.account_revenue = cls.env['account.account'].create({ - 'code': 'NC1114', - 'name': 'Sales - Test Sales Account', - 'user_type_id': user_type_revenue.id, - 'reconcile': True - }) - - @classmethod - def setUpAccountJournal(cls): - """ Set up some journals: sale, purchase, ... """ - cls.journal_purchase = cls.env['account.journal'].create({ - 'name': 'Purchase Journal - Test', - 'code': 'AJ-PURC', - 'type': 'purchase', - 'company_id': cls.env.user.company_id.id, - 'default_debit_account_id': cls.account_expense.id, - 'default_credit_account_id': cls.account_expense.id, - }) - cls.journal_sale = cls.env['account.journal'].create({ - 'name': 'Sale Journal - Test', - 'code': 'AJ-SALE', - 'type': 'sale', - 'company_id': cls.env.user.company_id.id, - 'default_debit_account_id': cls.account_income.id, - 'default_credit_account_id': cls.account_income.id, - }) - cls.journal_general = cls.env['account.journal'].create({ - 'name': 'General Journal - Test', - 'code': 'AJ-GENERAL', - 'type': 'general', - 'company_id': cls.env.user.company_id.id, - }) - - @classmethod - def setUpUsers(cls): - """ Create 2 users: an employee and a manager. Both will have correct account configured - on their partner. Others access rigths should be given in extending test suites set up. - """ - group_employee = cls.env.ref('base.group_user') - Users = cls.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True, 'mail_create_nolog': True}) - cls.user_employee = Users.create({ - 'name': 'Tyrion Lannister Employee', - 'login': 'tyrion', - 'email': 'tyrion@example.com', - 'notification_type': 'email', - 'groups_id': [(6, 0, [group_employee.id])], - }) - cls.user_manager = Users.create({ - 'name': 'Daenerys Targaryen Manager', - 'login': 'daenerys', - 'email': 'daenerys@example.com', - 'notification_type': 'email', - 'groups_id': [(6, 0, [group_employee.id])], - }) - account_values = { - 'property_account_payable_id': cls.account_payable.id, - 'property_account_receivable_id': cls.account_receivable.id, - } - cls.user_manager.partner_id.write(account_values) - cls.user_employee.partner_id.write(account_values) diff --git a/addons/account/tests/account_test_savepoint.py b/addons/account/tests/account_test_savepoint.py deleted file mode 100644 index 180b7a868c42..000000000000 --- a/addons/account/tests/account_test_savepoint.py +++ /dev/null @@ -1,209 +0,0 @@ -# -*- coding: utf-8 -*- - -import unittest - -from odoo import fields -from odoo.tests.common import Form, SavepointCase -from odoo.tests import tagged - - -@tagged('post_install', '-at_install') -class AccountingSavepointCase(SavepointCase): - - # ------------------------------------------------------------------------- - # DATA GENERATION - # ------------------------------------------------------------------------- - - @classmethod - def setUpClass(cls): - super(AccountingSavepointCase, cls).setUpClass() - - chart_template = cls.env.user.company_id.chart_template_id - if not chart_template: - chart_template = cls.env.ref('l10n_generic_coa.configurable_chart_template', raise_if_not_found=False) - if not chart_template: - cls.skipTest(cls, "Accounting Tests skipped because the user's company has no chart of accounts.") - - # Create user. - user = cls.env['res.users'].create({ - 'name': 'Because I am accountman!', - 'login': 'accountman', - 'groups_id': [(6, 0, cls.env.user.groups_id.ids)], - }) - user.partner_id.email = 'accountman@test.com' - - # Shadow the current environment/cursor with one having the report user. - # This is mandatory to test access rights. - cls.env = cls.env(user=user) - cls.cr = cls.env.cr - - cls.company_data = cls.setup_company_data('company_1_data') - cls.currency_data = cls.setup_multi_currency_data() - - @classmethod - def setup_company_data(cls, company_name, **kwargs): - ''' 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. - ''' - chart_template = cls.env.user.company_id.chart_template_id - company = cls.env['res.company'].create({ - 'name': company_name, - 'currency_id': cls.env.user.company_id.currency_id.id, - **kwargs, - }) - cls.env.user.company_ids |= company - cls.env.user.company_id = company - - chart_template = cls.env['account.chart.template'].browse(chart_template.id) - chart_template.try_loading() - - # The currency could be different after the installation of the chart template. - company.write({'currency_id': kwargs.get('currency_id', cls.env.user.company_id.currency_id.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': cls.env['account.account'].search([ - ('company_id', '=', company.id), - ('user_type_id.type', '=', 'receivable') - ], limit=1), - 'default_account_payable': cls.env['account.account'].search([ - ('company_id', '=', company.id), - ('user_type_id.type', '=', 'payable') - ], 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_tax_sale': company.account_sale_tax_id, - 'default_tax_purchase': company.account_purchase_tax_id, - } - - @classmethod - def setup_multi_currency_data(cls): - gold_currency = cls.env['res.currency'].create({ - 'name': 'Gold Coin', - 'symbol': '☺', - 'rounding': 0.001, - 'position': 'after', - 'currency_unit_label': 'Gold', - 'currency_subunit_label': 'Silver', - }) - rate1 = cls.env['res.currency.rate'].create({ - 'name': '2016-01-01', - 'rate': 3.0, - 'currency_id': gold_currency.id, - 'company_id': cls.env.company.id, - }) - rate2 = cls.env['res.currency.rate'].create({ - 'name': '2017-01-01', - 'rate': 2.0, - 'currency_id': gold_currency.id, - 'company_id': cls.env.company.id, - }) - return { - 'currency': gold_currency, - 'rates': rate1 + rate2, - } - - @classmethod - def setup_armageddon_tax(cls, tax_name, company_data): - return cls.env['account.tax'].create({ - 'name': '%s (group)' % tax_name, - 'amount_type': 'group', - 'amount': 0.0, - 'children_tax_ids': [ - (0, 0, { - 'name': '%s (child 1)' % tax_name, - 'amount_type': 'percent', - 'amount': 20.0, - 'price_include': True, - 'include_base_amount': True, - 'tax_exigibility': 'on_invoice', - 'invoice_repartition_line_ids': [ - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - (0, 0, { - 'factor_percent': 40, - 'repartition_type': 'tax', - 'account_id': company_data['default_account_tax_sale'].id, - }), - (0, 0, { - 'factor_percent': 60, - 'repartition_type': 'tax', - # /!\ No account set. - }), - ], - 'refund_repartition_line_ids': [ - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - (0, 0, { - 'factor_percent': 40, - 'repartition_type': 'tax', - 'account_id': company_data['default_account_tax_sale'].id, - }), - (0, 0, { - 'factor_percent': 60, - 'repartition_type': 'tax', - # /!\ No account set. - }), - ], - }), - (0, 0, { - 'name': '%s (child 2)' % tax_name, - 'amount_type': 'percent', - 'amount': 10.0, - 'tax_exigibility': 'on_payment', - 'cash_basis_transition_account_id': company_data['default_account_tax_sale'].copy().id, - 'invoice_repartition_line_ids': [ - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'tax', - 'account_id': company_data['default_account_tax_sale'].id, - }), - ], - 'refund_repartition_line_ids': [ - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - - (0, 0, { - 'factor_percent': 100, - 'repartition_type': 'tax', - 'account_id': company_data['default_account_tax_sale'].id, - }), - ], - }), - ], - }) diff --git a/addons/account/tests/account_test_users.py b/addons/account/tests/account_test_users.py deleted file mode 100644 index a9b7b30545dd..000000000000 --- a/addons/account/tests/account_test_users.py +++ /dev/null @@ -1,36 +0,0 @@ -from odoo.addons.account.tests.account_test_classes import AccountingTestCase - - -class AccountTestUsers(AccountingTestCase): - - """Tests for diffrent type of user 'Accountant/Adviser' and added groups""" - - @classmethod - def setUpClass(cls): - super(AccountTestUsers, cls).setUpClass() - cls.res_user_model = cls.env['res.users'] - cls.main_company = cls.env.ref('base.main_company') - cls.main_partner = cls.env.ref('base.main_partner') - cls.main_bank = cls.env.ref('base.res_bank_1') - res_users_account_user = cls.env.ref('account.group_account_invoice') - res_users_account_manager = cls.env.ref('account.group_account_manager') - partner_manager = cls.env.ref('base.group_partner_manager') - cls.tax_model = cls.env['account.tax'] - cls.account_model = cls.env['account.account'] - cls.account_type_model = cls.env['account.account.type'] - cls.currency_euro = cls.env.ref('base.EUR') - - cls.account_user = cls.res_user_model.with_context({'no_reset_password': True}).create(dict( - name="Accountant", - company_id=cls.main_company.id, - login="acc", - email="accountuser@yourcompany.com", - groups_id=[(6, 0, [res_users_account_user.id, partner_manager.id])] - )) - cls.account_manager = cls.res_user_model.with_context({'no_reset_password': True}).create(dict( - name="Adviser", - company_id=cls.main_company.id, - login="fm", - email="accountmanager@yourcompany.com", - groups_id=[(6, 0, [res_users_account_manager.id, partner_manager.id])] - )) diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py new file mode 100644 index 000000000000..b02d5cfab18b --- /dev/null +++ b/addons/account/tests/common.py @@ -0,0 +1,1031 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import logging +import time + +from odoo import fields +from odoo.addons.base.tests.common import SavepointCaseWithUserDemo +from odoo.exceptions import ValidationError +from odoo.tests.common import SavepointCase, HttpCase, tagged, Form + +import logging + +_logger = logging.getLogger(__name__) + + +class AccountTestCommon(SavepointCase): + """ This should be loaded for non python tests in other modules that require + accounting test data but that don't depend on any localization""" + + @classmethod + def setUpClass(cls): + super(AccountTestCommon, cls).setUpClass() + cls.create_accounting_minimal_data() + + @classmethod + def create_accounting_minimal_data(cls): + cls.company = cls.env.company + cls.company.bank_account_code_prefix = 'X1100' + + # Chart of Accounts + + # Account Tags + cls.demo_capital_account = cls.env['account.account.tag'].create({'name': 'Demo Capital Account'}) + cls.demo_stock_account = cls.env['account.account.tag'].create({'name': 'Demo Stock Account'}) + cls.demo_sale_of_land_account = cls.env['account.account.tag'].create({'name': 'Demo Sale of Land Account'}) + cls.demo_ceo_wages_account = cls.env['account.account.tag'].create({'name': 'Demo CEO Wages Account'}) + cls.demo_office_furniture_account = cls.env['account.account.tag'].create({'name': 'Office Furniture'}) + + # Balance Sheet + cls.xfa = cls.env['account.account'].create({ + 'code': 'X1000', + 'name': 'Fixed Assets - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id, + }) + cls.cas = cls.env['account.account'].create({ + 'code': 'X1010', + 'name': 'Current Assets - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + }) + cls.stk = cls.env['account.account'].create({ + 'code': 'X1011', + 'name': 'Purchased Stocks - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'tag_ids': [(6, 0, [cls.demo_stock_account.id])] + }) + cls.a_recv = cls.env['account.account'].create({ + 'code': 'X1012', + 'name': 'Debtors - (test)', + 'reconcile': True, + 'user_type_id': cls.env.ref('account.data_account_type_receivable').id, + }) + cls.ova = cls.env['account.account'].create({ + 'code': 'X1013', + 'name': 'VAT Paid- (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + }) + cls.bnk = cls.env['account.account'].create({ + 'code': 'X1014', + 'name': 'Bank Current Account - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, + }) + cls.cash = cls.env['account.account'].create({ + 'code': 'X1015', + 'name': 'Cash - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, + }) + cls.o_income = cls.env['account.account'].create({ + 'code': 'X1016', + 'name': 'Opening Income - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_other_income').id, + }) + cls.usd_bnk = cls.env['account.account'].create({ + 'code': 'X1017', + 'name': 'USD Bank Account - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_liquidity').id, + 'currency_id': cls.env.ref('base.USD').id, + }) + cls.transfer_account = cls.env['account.account'].create({ + 'code': 'X1019', + 'name': 'Internal Transfert Account - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'reconcile': True, + }) + cls.ncas = cls.env['account.account'].create({ + 'code': 'X1020', + 'name': 'Non-current Assets - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_non_current_assets').id, + }) + cls.prepayements = cls.env['account.account'].create({ + 'code': 'X1030', + 'name': 'Prepayments - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_prepayments').id, + }) + cls.current_liabilities = cls.env['account.account'].create({ + 'code': 'X1110', + 'name': 'Current Liabilities - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, + }) + cls.a_pay = cls.env['account.account'].create({ + 'code': 'X1111', + 'name': 'Creditors - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_payable').id, + 'reconcile': True, + }) + cls.iva = cls.env['account.account'].create({ + 'code': 'X1112', + 'name': 'VAT Received - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, + }) + cls.rsa = cls.env['account.account'].create({ + 'code': 'X1113', + 'name': 'Reserve and Profit/Loss - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, + }) + cls.cas = cls.env['account.account'].create({ + 'code': 'X1120', + 'name': 'Non-current Liabilities - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_non_current_liabilities').id, + }) + cls.o_expense = cls.env['account.account'].create({ + 'code': 'X1114', + 'name': 'Opening Expense - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + }) + + # Profit and Loss + cls.income_fx_income = cls.env['account.account'].create({ + 'code': 'X2010', + 'name': 'Foreign Exchange Gain - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'reconcile': False, + }) + cls.a_sale = cls.env['account.account'].create({ + 'code': 'X2020', + 'name': 'Product Sales - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], + }) + cls.a_sale_invest = cls.env['account.account'].create({ + 'code': 'X2021', + 'name': 'Sale of Lands - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])], + }) + cls.a_sale_finance = cls.env['account.account'].create({ + 'code': 'X2022', + 'name': 'Bank Accounts Interests - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])], + }) + cls.a_sale_finance = cls.env['account.account'].create({ + 'code': 'X2030', + 'name': 'Cost of Goods Sold - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_direct_costs').id, + }) + cls.income_fx_expense = cls.env['account.account'].create({ + 'code': 'X2110', + 'name': 'Foreign Exchange Loss - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + 'reconcile': False, + }) + cls.a_expense = cls.env['account.account'].create({ + 'code': 'X2120', + 'name': 'Expenses - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], + }) + cls.a_salary_expense = cls.env['account.account'].create({ + 'code': 'X2121', + 'name': 'Salary Expenses - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_operating').id])], + }) + cls.a_expense_invest = cls.env['account.account'].create({ + 'code': 'X2122', + 'name': 'Purchase of Equipments - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_fixed_assets').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_investing').id])], + }) + cls.a_expense_finance = cls.env['account.account'].create({ + 'code': 'X2123', + 'name': 'Bank Fees - (test)', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + 'tag_ids': [(6, 0, [cls.env.ref('account.account_tag_financing').id])], + }) + cls.a_capital = cls.env['account.account'].create({ + 'code': 'X3001', + 'name': 'Capital', + 'user_type_id': cls.env.ref('account.data_account_type_equity').id, + }) + cls.a_dividends = cls.env['account.account'].create({ + 'code': 'X3002', + 'name': 'Dividends', + 'user_type_id': cls.env.ref('account.data_account_type_equity').id, + }) + + # Properties: Product income and expense accounts, default parameters + cls.env['ir.property'].create([{ + 'name': 'property_account_receivable_id', + 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_receivable_id')], limit=1).id, + 'value': 'account.account,%s' % (cls.a_recv.id), + 'company_id': cls.company.id, + }, { + 'name': 'property_account_payable_id', + 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_payable_id')], limit=1).id, + 'value': 'account.account,%s' % (cls.a_pay.id), + 'company_id': cls.company.id, + }, { + 'name': 'property_account_position_id', + 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_account_position_id')], limit=1).id, + 'value': False, + 'company_id': cls.company.id, + }, { + 'name': 'property_account_expense_categ_id', + 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_expense_categ_id')], limit=1).id, + 'value': 'account.account,%s' % (cls.a_expense.id), + 'company_id': cls.company.id, + }, { + 'name': 'property_account_income_categ_id', + 'fields_id': cls.env['ir.model.fields'].search([('model', '=', 'product.category'), ('name', '=', 'property_account_income_categ_id')], limit=1).id, + 'value': 'account.account,%s' % (cls.a_sale.id), + 'company_id': cls.company.id, + }]) + + # Bank Accounts + cls.bank_account = cls.env['res.partner.bank'].create({ + 'acc_number': '987654321', + 'bank_name': 'Bank', + 'partner_id': cls.company.partner_id.id, + }) + cls.bank_account_usd = cls.env['res.partner.bank'].create({ + 'acc_number': '123456789', + 'bank_name': 'Bank US', + 'partner_id': cls.company.partner_id.id, + }) + + # Account Journal + cls.sales_journal = cls.env['account.journal'].create({ + 'name': 'Customer Invoices - Test', + 'code': 'TINV', + 'type': 'sale', + 'default_credit_account_id': cls.a_sale.id, + 'default_debit_account_id': cls.a_sale.id, + 'refund_sequence': True, + }) + cls.expenses_journal = cls.env['account.journal'].create({ + 'name': 'Vendor Bills - Test', + 'code': 'TEXJ', + 'type': 'purchase', + 'default_credit_account_id': cls.a_expense.id, + 'default_debit_account_id': cls.a_expense.id, + 'refund_sequence': True, + }) + cls.bank_journal = cls.env['account.journal'].create({ + 'name': 'Bank - Test', + 'code': 'TBNK', + 'type': 'bank', + 'default_credit_account_id': cls.bnk.id, + 'default_debit_account_id': cls.bnk.id, + }) + cls.cash_journal = cls.env['account.journal'].create({ + 'name': 'Cash - Test', + 'code': 'TCSH', + 'type': 'cash', + 'profit_account_id': cls.rsa.id, + 'loss_account_id': cls.rsa.id, + 'default_credit_account_id': cls.cash.id, + 'default_debit_account_id': cls.cash.id, + }) + cls.miscellaneous_journal = cls.env['account.journal'].create({ + 'name': 'Miscellaneous - Test', + 'code': 'TMIS', + 'type': 'general', + 'show_on_dashboard': False, + }) + cls.currency_diff_journal = cls.env['account.journal'].create({ + 'name': 'Currency Difference - Test', + 'code': 'CUR', + 'type': 'general', + 'default_credit_account_id': cls.income_fx_expense.id, + 'default_debit_account_id': cls.income_fx_income.id, + 'show_on_dashboard': False, + }) + cls.bank_journal_usd = cls.env['account.journal'].create({ + 'name': 'USD Bank - Test', + 'code': 'TUBK', + 'type': 'bank', + 'default_credit_account_id': cls.usd_bnk.id, + 'default_debit_account_id': cls.usd_bnk.id, + 'bank_account_id': cls.bank_account_usd.id, + }) + + cls.company.currency_exchange_journal_id = cls.currency_diff_journal.id + + +class AccountTestUsersCommon(AccountTestCommon): + + """Tests for diffrent type of user 'Accountant/Adviser' and added groups""" + + @classmethod + def setUpClass(cls): + super(AccountTestUsersCommon, cls).setUpClass() + cls.res_user_model = cls.env['res.users'] + cls.main_company = cls.env.ref('base.main_company') + cls.main_partner = cls.env.ref('base.main_partner') + cls.main_bank = cls.env.ref('base.res_bank_1') + res_users_account_user = cls.env.ref('account.group_account_invoice') + res_users_account_manager = cls.env.ref('account.group_account_manager') + partner_manager = cls.env.ref('base.group_partner_manager') + cls.tax_model = cls.env['account.tax'] + cls.account_model = cls.env['account.account'] + cls.account_type_model = cls.env['account.account.type'] + cls.currency_euro = cls.env.ref('base.EUR') + + cls.account_user = cls.res_user_model.with_context({'no_reset_password': True}).create(dict( + name="Accountant", + company_id=cls.main_company.id, + login="acc", + email="accountuser@yourcompany.com", + groups_id=[(6, 0, [res_users_account_user.id, partner_manager.id])] + )) + cls.account_manager = cls.res_user_model.with_context({'no_reset_password': True}).create(dict( + name="Adviser", + company_id=cls.main_company.id, + login="fm", + email="accountmanager@yourcompany.com", + groups_id=[(6, 0, [res_users_account_manager.id, partner_manager.id])] + )) + + +class AccountTestNoChartCommon(SavepointCaseWithUserDemo): + """ Some tests required to be executed at module installation, and not 'post install', like moslty + of accounting tests, since a chart of account is required + This test setup class provides data for test suite to make business flow working without a chart + of account installed. The class provide some helpers methods to create particular document types. Each + test suite extending this method can call thoses method to set up their testing environment in their + own `setUpClass` method. + """ + + @classmethod + def setUpClass(cls): + """ This method set up the minimal requried part of chart of account """ + super(AccountTestNoChartCommon, cls).setUpClass() + # To speed up test, create object without mail tracking + context_no_mail = {'no_reset_password': True, 'mail_create_nosubscribe': True, 'mail_create_nolog': True} + + # Create base account to simulate a chart of account + user_type_payable = cls.env.ref('account.data_account_type_payable') + cls.account_payable = cls.env['account.account'].create({ + 'code': 'NC1110', + 'name': 'Test Payable Account', + 'user_type_id': user_type_payable.id, + 'reconcile': True + }) + user_type_receivable = cls.env.ref('account.data_account_type_receivable') + cls.account_receivable = cls.env['account.account'].create({ + 'code': 'NC1111', + 'name': 'Test Receivable Account', + 'user_type_id': user_type_receivable.id, + 'reconcile': True + }) + + # Create a customer + Partner = cls.env['res.partner'].with_context(context_no_mail) + cls.partner_customer_usd = Partner.create({ + 'name': 'Customer from the North', + 'email': 'customer.usd@north.com', + 'property_account_payable_id': cls.account_payable.id, + 'property_account_receivable_id': cls.account_receivable.id, + 'company_id': cls.env.ref('base.main_company').id + }) + + cls.sale_journal0 = cls.env['account.journal'].create({ + 'name': 'Sale Journal', + 'type': 'sale', + 'code': 'SJT0', + }) + + @classmethod + def setUpAdditionalAccounts(cls): + """ Set up some addionnal accounts: expenses, revenue, ... """ + user_type_income = cls.env.ref('account.data_account_type_direct_costs') + cls.account_income = cls.env['account.account'].create({ + 'code': 'NC1112', 'name': + 'Sale - Test Account', + 'user_type_id': user_type_income.id + }) + user_type_expense = cls.env.ref('account.data_account_type_expenses') + cls.account_expense = cls.env['account.account'].create({ + 'code': 'NC1113', + 'name': 'HR Expense - Test Purchase Account', + 'user_type_id': user_type_expense.id + }) + user_type_revenue = cls.env.ref('account.data_account_type_revenue') + cls.account_revenue = cls.env['account.account'].create({ + 'code': 'NC1114', + 'name': 'Sales - Test Sales Account', + 'user_type_id': user_type_revenue.id, + 'reconcile': True + }) + + @classmethod + def setUpAccountJournal(cls): + """ Set up some journals: sale, purchase, ... """ + cls.journal_purchase = cls.env['account.journal'].create({ + 'name': 'Purchase Journal - Test', + 'code': 'AJ-PURC', + 'type': 'purchase', + 'company_id': cls.env.user.company_id.id, + 'default_debit_account_id': cls.account_expense.id, + 'default_credit_account_id': cls.account_expense.id, + }) + cls.journal_sale = cls.env['account.journal'].create({ + 'name': 'Sale Journal - Test', + 'code': 'AJ-SALE', + 'type': 'sale', + 'company_id': cls.env.user.company_id.id, + 'default_debit_account_id': cls.account_income.id, + 'default_credit_account_id': cls.account_income.id, + }) + cls.journal_general = cls.env['account.journal'].create({ + 'name': 'General Journal - Test', + 'code': 'AJ-GENERAL', + 'type': 'general', + 'company_id': cls.env.user.company_id.id, + }) + + @classmethod + def setUpUsers(cls): + """ Create 2 users: an employee and a manager. Both will have correct account configured + on their partner. Others access rigths should be given in extending test suites set up. + """ + group_employee = cls.env.ref('base.group_user') + Users = cls.env['res.users'].with_context({'no_reset_password': True, 'mail_create_nosubscribe': True, 'mail_create_nolog': True}) + cls.user_employee = Users.create({ + 'name': 'Tyrion Lannister Employee', + 'login': 'tyrion', + 'email': 'tyrion@example.com', + 'notification_type': 'email', + 'groups_id': [(6, 0, [group_employee.id])], + }) + cls.user_manager = Users.create({ + 'name': 'Daenerys Targaryen Manager', + 'login': 'daenerys', + 'email': 'daenerys@example.com', + 'notification_type': 'email', + 'groups_id': [(6, 0, [group_employee.id])], + }) + account_values = { + 'property_account_payable_id': cls.account_payable.id, + 'property_account_receivable_id': cls.account_receivable.id, + } + cls.user_manager.partner_id.write(account_values) + cls.user_employee.partner_id.write(account_values) + + +@tagged('post_install', '-at_install') +class AccountTestInvoicingCommon(SavepointCase): + + @classmethod + def setUpClass(cls): + super(AccountTestInvoicingCommon, cls).setUpClass() + + chart_template = cls.env.user.company_id.chart_template_id + if not chart_template: + chart_template = cls.env.ref('l10n_generic_coa.configurable_chart_template', raise_if_not_found=False) + if not chart_template: + cls.skipTest(cls, "Accounting Tests skipped because the user's company has no chart of accounts.") + + # Create user. + user = cls.env['res.users'].create({ + 'name': 'Because I am accountman!', + 'login': 'accountman', + 'groups_id': [(6, 0, cls.env.user.groups_id.ids)], + }) + user.partner_id.email = 'accountman@test.com' + + # Shadow the current environment/cursor with one having the report user. + # This is mandatory to test access rights. + cls.env = cls.env(user=user) + cls.cr = cls.env.cr + + cls.company_data = cls.setup_company_data('company_1_data') + cls.currency_data = cls.setup_multi_currency_data() + + # ==== Taxes ==== + 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) + + # ==== Products ==== + 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.company_data['default_account_revenue'].copy().id, + 'property_account_expense_id': cls.company_data['default_account_expense'].copy().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)], + }) + + # ==== Fiscal positions ==== + 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, + }), + ], + }) + + # ==== Payment terms ==== + 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', + }), + ], + }) + + # ==== Partners ==== + 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, + }) + + # ==== Cash rounding ==== + cls.cash_rounding_a = cls.env['account.cash.rounding'].create({ + 'name': 'add_invoice_line', + 'rounding': 0.05, + 'strategy': 'add_invoice_line', + 'account_id': cls.company_data['default_account_revenue'].copy().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 setup_company_data(cls, company_name, **kwargs): + ''' 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. + ''' + chart_template = cls.env.user.company_id.chart_template_id + company = cls.env['res.company'].create({ + 'name': company_name, + 'currency_id': cls.env.user.company_id.currency_id.id, + **kwargs, + }) + cls.env.user.company_ids |= company + cls.env.user.company_id = company + + chart_template = cls.env['account.chart.template'].browse(chart_template.id) + chart_template.try_loading() + + # The currency could be different after the installation of the chart template. + company.write({'currency_id': kwargs.get('currency_id', cls.env.user.company_id.currency_id.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': cls.env['account.account'].search([ + ('company_id', '=', company.id), + ('user_type_id.type', '=', 'receivable') + ], limit=1), + 'default_account_payable': cls.env['account.account'].search([ + ('company_id', '=', company.id), + ('user_type_id.type', '=', 'payable') + ], 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_tax_sale': company.account_sale_tax_id, + 'default_tax_purchase': company.account_purchase_tax_id, + } + + @classmethod + def setup_multi_currency_data(cls): + gold_currency = cls.env['res.currency'].create({ + 'name': 'Gold Coin', + 'symbol': '☺', + 'rounding': 0.001, + 'position': 'after', + 'currency_unit_label': 'Gold', + 'currency_subunit_label': 'Silver', + }) + rate1 = cls.env['res.currency.rate'].create({ + 'name': '2016-01-01', + 'rate': 3.0, + 'currency_id': gold_currency.id, + 'company_id': cls.env.company.id, + }) + rate2 = cls.env['res.currency.rate'].create({ + 'name': '2017-01-01', + 'rate': 2.0, + 'currency_id': gold_currency.id, + 'company_id': cls.env.company.id, + }) + return { + 'currency': gold_currency, + 'rates': rate1 + rate2, + } + + @classmethod + def setup_armageddon_tax(cls, tax_name, company_data): + return cls.env['account.tax'].create({ + 'name': '%s (group)' % tax_name, + 'amount_type': 'group', + 'amount': 0.0, + 'children_tax_ids': [ + (0, 0, { + 'name': '%s (child 1)' % tax_name, + 'amount_type': 'percent', + 'amount': 20.0, + 'price_include': True, + 'include_base_amount': True, + 'tax_exigibility': 'on_invoice', + 'invoice_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + (0, 0, { + 'factor_percent': 40, + 'repartition_type': 'tax', + 'account_id': company_data['default_account_tax_sale'].id, + }), + (0, 0, { + 'factor_percent': 60, + 'repartition_type': 'tax', + # /!\ No account set. + }), + ], + 'refund_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + (0, 0, { + 'factor_percent': 40, + 'repartition_type': 'tax', + 'account_id': company_data['default_account_tax_sale'].id, + }), + (0, 0, { + 'factor_percent': 60, + 'repartition_type': 'tax', + # /!\ No account set. + }), + ], + }), + (0, 0, { + 'name': '%s (child 2)' % tax_name, + 'amount_type': 'percent', + 'amount': 10.0, + 'tax_exigibility': 'on_payment', + 'cash_basis_transition_account_id': company_data['default_account_tax_sale'].copy().id, + 'invoice_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + 'account_id': company_data['default_account_tax_sale'].id, + }), + ], + 'refund_repartition_line_ids': [ + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + + (0, 0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + 'account_id': company_data['default_account_tax_sale'].id, + }), + ], + }), + ], + }) + + @classmethod + def init_invoice(cls, move_type): + move_form = Form(cls.env['account.move'].with_context(default_type=move_type)) + move_form.invoice_date = fields.Date.from_string('2019-01-01') + move_form.partner_id = cls.partner_a + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = cls.product_a + with move_form.invoice_line_ids.new() as line_form: + line_form.product_id = cls.product_b + return move_form.save() + + def assertInvoiceValues(self, move, expected_lines_values, expected_move_values): + def sort_lines(lines): + return lines.sorted(lambda line: (line.exclude_from_invoice_tab, not bool(line.tax_line_id), line.name or '', line.balance)) + self.assertRecordValues(sort_lines(move.line_ids.sorted()), expected_lines_values) + self.assertRecordValues(sort_lines(move.invoice_line_ids.sorted()), expected_lines_values[:len(move.invoice_line_ids)]) + self.assertRecordValues(move, [expected_move_values]) + + +class TestAccountReconciliationCommon(AccountTestCommon): + + """Tests for reconciliation (account.tax) + + Test used to check that when doing a sale or purchase invoice in a different currency, + the result will be balanced. + """ + + @classmethod + def setUpClass(cls): + super(TestAccountReconciliationCommon, cls).setUpClass() + cls.company = cls.env['res.company'].create({ + 'name': 'A test company', + 'currency_id': cls.env.ref('base.EUR').id + }) + cls.env.user.company_id = cls.company + # Generate minimal data for my new company + cls.create_accounting_minimal_data() + + cls.acc_bank_stmt_model = cls.env['account.bank.statement'] + cls.acc_bank_stmt_line_model = cls.env['account.bank.statement.line'] + cls.res_currency_model = cls.registry('res.currency') + cls.res_currency_rate_model = cls.registry('res.currency.rate') + + cls.partner_agrolait = cls.env['res.partner'].create({ + 'name': 'Deco Addict', + 'is_company': True, + 'country_id': cls.env.ref('base.us').id, + }) + cls.partner_agrolait_id = cls.partner_agrolait.id + cls.currency_swiss_id = cls.env.ref("base.CHF").id + cls.currency_usd_id = cls.env.ref("base.USD").id + cls.currency_euro_id = cls.env.ref("base.EUR").id + # YTI FIXME Some of those lines should be useless now + cls.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [cls.currency_euro_id, cls.company.id]) + cls.account_rcv = cls.partner_agrolait.property_account_receivable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_receivable').id)], limit=1) + cls.account_rsa = cls.partner_agrolait.property_account_payable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_payable').id)], limit=1) + cls.product = cls.env['product.product'].create({ + 'name': 'Product Product 4', + 'standard_price': 500.0, + 'list_price': 750.0, + 'type': 'consu', + 'categ_id': cls.env.ref('product.product_category_all').id, + }) + + cls.bank_journal_euro = cls.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'}) + cls.account_euro = cls.bank_journal_euro.default_debit_account_id + + cls.bank_journal_usd = cls.env['account.journal'].create({'name': 'Bank US', 'type': 'bank', 'code': 'BNK68', 'currency_id': cls.currency_usd_id}) + cls.account_usd = cls.bank_journal_usd.default_debit_account_id + + cls.fx_journal = cls.env['res.users'].browse(cls.env.uid).company_id.currency_exchange_journal_id + cls.diff_income_account = cls.env['res.users'].browse(cls.env.uid).company_id.income_currency_exchange_account_id + cls.diff_expense_account = cls.env['res.users'].browse(cls.env.uid).company_id.expense_currency_exchange_account_id + + cls.inbound_payment_method = cls.env['account.payment.method'].create({ + 'name': 'inbound', + 'code': 'IN', + 'payment_type': 'inbound', + }) + + cls.expense_account = cls.env['account.account'].create({ + 'name': 'EXP', + 'code': 'EXP', + 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, + 'company_id': cls.company.id, + }) + # cash basis intermediary account + cls.tax_waiting_account = cls.env['account.account'].create({ + 'name': 'TAX_WAIT', + 'code': 'TWAIT', + 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, + 'reconcile': True, + 'company_id': cls.company.id, + }) + # cash basis final account + cls.tax_final_account = cls.env['account.account'].create({ + 'name': 'TAX_TO_DEDUCT', + 'code': 'TDEDUCT', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'company_id': cls.company.id, + }) + cls.tax_base_amount_account = cls.env['account.account'].create({ + 'name': 'TAX_BASE', + 'code': 'TBASE', + 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, + 'company_id': cls.company.id, + }) + + # Journals + cls.purchase_journal = cls.env['account.journal'].create({ + 'name': 'purchase', + 'code': 'PURCH', + 'type': 'purchase', + 'default_credit_account_id': cls.a_expense.id, + 'default_debit_account_id': cls.a_expense.id, + }) + cls.cash_basis_journal = cls.env['account.journal'].create({ + 'name': 'CABA', + 'code': 'CABA', + 'type': 'general', + }) + cls.general_journal = cls.env['account.journal'].create({ + 'name': 'general', + 'code': 'GENE', + 'type': 'general', + }) + + # Tax Cash Basis + cls.tax_cash_basis = cls.env['account.tax'].create({ + 'name': 'cash basis 20%', + 'type_tax_use': 'purchase', + 'company_id': cls.company.id, + 'amount': 20, + 'tax_exigibility': 'on_payment', + 'cash_basis_transition_account_id': cls.tax_waiting_account.id, + 'cash_basis_base_account_id': cls.tax_base_amount_account.id, + 'invoice_repartition_line_ids': [ + (0,0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + + (0,0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + 'account_id': cls.tax_final_account.id, + }), + ], + 'refund_repartition_line_ids': [ + (0,0, { + 'factor_percent': 100, + 'repartition_type': 'base', + }), + + (0,0, { + 'factor_percent': 100, + 'repartition_type': 'tax', + 'account_id': cls.tax_final_account.id, + }), + ], + }) + cls.env['res.currency.rate'].create([ + { + 'currency_id': cls.env.ref('base.EUR').id, + 'name': '2010-01-02', + 'rate': 1.0, + }, { + 'currency_id': cls.env.ref('base.USD').id, + 'name': '2010-01-02', + 'rate': 1.2834, + }, { + 'currency_id': cls.env.ref('base.USD').id, + 'name': time.strftime('%Y-06-05'), + 'rate': 1.5289, + } + ]) + + def _create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None, partner_id=None, date_invoice=None, payment_term_id=False, auto_validate=False): + date_invoice = date_invoice or time.strftime('%Y') + '-07-01' + + invoice_vals = { + 'type': type, + 'partner_id': partner_id or self.partner_agrolait_id, + 'invoice_date': date_invoice, + 'date': date_invoice, + 'invoice_line_ids': [(0, 0, { + 'name': 'product that cost %s' % invoice_amount, + 'quantity': 1, + 'price_unit': invoice_amount, + 'tax_ids': [(6, 0, [])], + })] + } + + if payment_term_id: + invoice_vals['invoice_payment_term_id'] = payment_term_id + + if currency_id: + invoice_vals['currency_id'] = currency_id + + invoice = self.env['account.move'].with_context(default_type=type).create(invoice_vals) + if auto_validate: + invoice.post() + return invoice + + def create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None): + return self._create_invoice(type=type, invoice_amount=invoice_amount, currency_id=currency_id, auto_validate=True) + + def create_invoice_partner(self, type='out_invoice', invoice_amount=50, currency_id=None, partner_id=False, payment_term_id=False): + return self._create_invoice( + type=type, + invoice_amount=invoice_amount, + currency_id=currency_id, + partner_id=partner_id, + payment_term_id=payment_term_id, + auto_validate=True + ) + + def make_payment(self, invoice_record, bank_journal, amount=0.0, amount_currency=0.0, currency_id=None): + bank_stmt = self.acc_bank_stmt_model.create({ + 'journal_id': bank_journal.id, + 'date': time.strftime('%Y') + '-07-15', + 'name': 'payment' + invoice_record.name + }) + + bank_stmt_line = self.acc_bank_stmt_line_model.create({'name': 'payment', + 'statement_id': bank_stmt.id, + 'partner_id': self.partner_agrolait_id, + 'amount': amount, + 'amount_currency': amount_currency, + 'currency_id': currency_id, + 'date': time.strftime('%Y') + '-07-15', + }) + line_id = invoice_record.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) + amount_in_widget = currency_id and amount_currency or amount + bank_stmt_line.process_reconciliation(counterpart_aml_dicts=[{ + 'move_line': line_id, + 'debit': amount_in_widget < 0 and -amount_in_widget or 0.0, + 'credit': amount_in_widget > 0 and amount_in_widget or 0.0, + 'name': line_id.name, + }]) + return bank_stmt + + def make_customer_and_supplier_flows(self, invoice_currency_id, invoice_amount, bank_journal, amount, amount_currency, transaction_currency_id): + #we create an invoice in given invoice_currency + invoice_record = self.create_invoice(type='out_invoice', invoice_amount=invoice_amount, currency_id=invoice_currency_id) + #we encode a payment on it, on the given bank_journal with amount, amount_currency and transaction_currency given + bank_stmt = self.make_payment(invoice_record, bank_journal, amount=amount, amount_currency=amount_currency, currency_id=transaction_currency_id) + customer_move_lines = bank_stmt.move_line_ids + + #we create a supplier bill in given invoice_currency + invoice_record = self.create_invoice(type='in_invoice', invoice_amount=invoice_amount, currency_id=invoice_currency_id) + #we encode a payment on it, on the given bank_journal with amount, amount_currency and transaction_currency given + bank_stmt = self.make_payment(invoice_record, bank_journal, amount=-amount, amount_currency=-amount_currency, currency_id=transaction_currency_id) + supplier_move_lines = bank_stmt.move_line_ids + return customer_move_lines, supplier_move_lines diff --git a/addons/account/tests/invoice_test_common.py b/addons/account/tests/invoice_test_common.py deleted file mode 100644 index 16dcd0dabd89..000000000000 --- a/addons/account/tests/invoice_test_common.py +++ /dev/null @@ -1,147 +0,0 @@ -# -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_savepoint import AccountingSavepointCase -from odoo.tests.common import Form -from odoo.tests import tagged -from odoo.exceptions import ValidationError -from odoo import fields - -import logging - -_logger = logging.getLogger(__name__) - - -@tagged('post_install', '-at_install') -class InvoiceTestCommon(AccountingSavepointCase): - - @classmethod - def setUpClass(cls): - super(InvoiceTestCommon, cls).setUpClass() - - # ==== Taxes ==== - 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) - - # ==== Products ==== - 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.company_data['default_account_revenue'].copy().id, - 'property_account_expense_id': cls.company_data['default_account_expense'].copy().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)], - }) - - # ==== Fiscal positions ==== - 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, - }), - ], - }) - - # ==== Payment terms ==== - 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', - }), - ], - }) - - # ==== Partners ==== - 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, - }) - - # ==== Cash rounding ==== - cls.cash_rounding_a = cls.env['account.cash.rounding'].create({ - 'name': 'add_invoice_line', - 'rounding': 0.05, - 'strategy': 'add_invoice_line', - 'account_id': cls.company_data['default_account_revenue'].copy().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 init_invoice(cls, move_type): - move_form = Form(cls.env['account.move'].with_context(default_type=move_type)) - move_form.invoice_date = fields.Date.from_string('2019-01-01') - move_form.partner_id = cls.partner_a - with move_form.invoice_line_ids.new() as line_form: - line_form.product_id = cls.product_a - with move_form.invoice_line_ids.new() as line_form: - line_form.product_id = cls.product_b - return move_form.save() - - def assertInvoiceValues(self, move, expected_lines_values, expected_move_values): - def sort_lines(lines): - return lines.sorted(lambda line: (line.exclude_from_invoice_tab, not bool(line.tax_line_id), line.name or '', line.balance)) - self.assertRecordValues(sort_lines(move.line_ids.sorted()), expected_lines_values) - self.assertRecordValues(sort_lines(move.invoice_line_ids.sorted()), expected_lines_values[:len(move.invoice_line_ids)]) - self.assertRecordValues(move, [expected_move_values]) diff --git a/addons/account/tests/test_account_bank_statement.py b/addons/account/tests/test_account_bank_statement.py index 5b479387f3f0..6cd7b9820d72 100644 --- a/addons/account/tests/test_account_bank_statement.py +++ b/addons/account/tests/test_account_bank_statement.py @@ -1,9 +1,9 @@ -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestBankStatement(AccountingTestCase): +class TestBankStatement(AccountTestCommon): def setUp(self): super(TestBankStatement, self).setUp() diff --git a/addons/account/tests/test_account_fiscal_year.py b/addons/account/tests/test_account_fiscal_year.py index 0bbf73249aaf..8ab006bbf6d2 100644 --- a/addons/account/tests/test_account_fiscal_year.py +++ b/addons/account/tests/test_account_fiscal_year.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon import odoo.tests from odoo import fields @@ -8,7 +8,7 @@ from datetime import datetime @odoo.tests.tagged('post_install', '-at_install') -class TestFiscalPosition(AccountingTestCase): +class TestFiscalPosition(AccountTestCommon): def check_compute_fiscal_year(self, company, date, expected_date_from, expected_date_to): '''Compute the fiscal year at a certain date for the company passed as parameter. diff --git a/addons/account/tests/test_account_invoice_report.py b/addons/account/tests/test_account_invoice_report.py index d54f4e944d85..bc4d6e2e27ba 100644 --- a/addons/account/tests/test_account_invoice_report.py +++ b/addons/account/tests/test_account_invoice_report.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import Form from odoo.tests import tagged from odoo import fields @@ -8,7 +8,7 @@ from unittest.mock import patch @tagged('post_install', '-at_install') -class TestAccountInvoiceReport(InvoiceTestCommon): +class TestAccountInvoiceReport(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_journal_dashboard.py b/addons/account/tests/test_account_journal_dashboard.py index 19a7bbdab597..cb9ffb953751 100644 --- a/addons/account/tests/test_account_journal_dashboard.py +++ b/addons/account/tests/test_account_journal_dashboard.py @@ -1,11 +1,11 @@ from unittest.mock import patch -from odoo.addons.account.tests.account_test_users import AccountTestUsers +from odoo.addons.account.tests.common import AccountTestUsersCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestAccountJournalDashboard(AccountTestUsers): +class TestAccountJournalDashboard(AccountTestUsersCommon): def test_customer_invoice_dashboard(self): def patched_today(*args, **kwargs): return '2019-01-22' diff --git a/addons/account/tests/test_account_move_entry.py b/addons/account/tests/test_account_move_entry.py index d10bbab526de..bd14ff00dc52 100644 --- a/addons/account/tests/test_account_move_entry.py +++ b/addons/account/tests/test_account_move_entry.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests import tagged, new_test_user from odoo import fields from odoo.exceptions import ValidationError, UserError @@ -8,7 +8,7 @@ from dateutil.relativedelta import relativedelta @tagged('post_install', '-at_install') -class TestAccountMove(InvoiceTestCommon): +class TestAccountMove(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index fe6692d99d8e..9dd2a87a36fd 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import Form from odoo.tests import tagged from odoo import fields @@ -7,7 +7,7 @@ from odoo.exceptions import ValidationError @tagged('post_install', '-at_install') -class TestAccountMoveInInvoiceOnchanges(InvoiceTestCommon): +class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_move_in_refund.py b/addons/account/tests/test_account_move_in_refund.py index e89b81c98a7c..2b883297f598 100644 --- a/addons/account/tests/test_account_move_in_refund.py +++ b/addons/account/tests/test_account_move_in_refund.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import Form from odoo.tests import tagged from odoo import fields @tagged('post_install', '-at_install') -class TestAccountMoveInRefundOnchanges(InvoiceTestCommon): +class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index 38a54508910e..2556fbcc9cd1 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import Form from odoo.tests import tagged from odoo import fields @@ -9,7 +9,7 @@ from unittest.mock import patch @tagged('post_install', '-at_install') -class TestAccountMoveOutInvoiceOnchanges(InvoiceTestCommon): +class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_move_out_refund.py b/addons/account/tests/test_account_move_out_refund.py index 5d446553d619..8f87ec6563f8 100644 --- a/addons/account/tests/test_account_move_out_refund.py +++ b/addons/account/tests/test_account_move_out_refund.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.invoice_test_common import InvoiceTestCommon +from odoo.addons.account.tests.common import AccountTestInvoicingCommon from odoo.tests.common import Form from odoo.tests import tagged from odoo import fields @tagged('post_install', '-at_install') -class TestAccountMoveOutRefundOnchanges(InvoiceTestCommon): +class TestAccountMoveOutRefundOnchanges(AccountTestInvoicingCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_account_move_rounding.py b/addons/account/tests/test_account_move_rounding.py index 9ea27cb74bb1..5514ec05c576 100644 --- a/addons/account/tests/test_account_move_rounding.py +++ b/addons/account/tests/test_account_move_rounding.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestAccountMoveRounding(AccountingTestCase): +class TestAccountMoveRounding(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index 6061f5536441..37590f446469 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -1,9 +1,9 @@ -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestBankStatementReconciliation(AccountingTestCase): +class TestBankStatementReconciliation(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_control_journal_account.py b/addons/account/tests/test_control_journal_account.py index f558a96521ab..099ad7a80823 100644 --- a/addons/account/tests/test_control_journal_account.py +++ b/addons/account/tests/test_control_journal_account.py @@ -1,10 +1,10 @@ -from odoo.addons.account.tests.account_test_no_chart import TestAccountNoChartCommon +from odoo.addons.account.tests.common import AccountTestNoChartCommon from odoo.tests.common import tagged from odoo.exceptions import UserError, ValidationError @tagged('post_install', '-at_install') -class TestControlJournalAccount(TestAccountNoChartCommon): +class TestControlJournalAccount(AccountTestNoChartCommon): @classmethod def setUpClass(cls): super(TestControlJournalAccount, cls).setUpClass() diff --git a/addons/account/tests/test_invoice_taxes.py b/addons/account/tests/test_invoice_taxes.py index 0d4df086eba4..a297d7914f55 100644 --- a/addons/account/tests/test_invoice_taxes.py +++ b/addons/account/tests/test_invoice_taxes.py @@ -2,13 +2,13 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.base.tests.common import SavepointCaseWithUserDemo -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests.common import Form from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestInvoiceTaxes(AccountingTestCase, SavepointCaseWithUserDemo): +class TestInvoiceTaxes(AccountTestCommon, SavepointCaseWithUserDemo): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 8f560635e606..f155dccaff5b 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged from odoo.tests.common import Form import time @tagged('post_install', '-at_install') -class TestPayment(AccountingTestCase): +class TestPayment(AccountTestCommon): def setUp(self): self.env.ref('base.main_company').currency_id = self.env.ref('base.USD') diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 0877d1368bcd..bb56e66e8265 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -1,256 +1,18 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, tools -from odoo.addons.account.tests.account_test_classes import AccountingTestCase -from odoo.exceptions import UserError -from odoo.tests import Form, tagged import time -from datetime import timedelta import unittest +from datetime import timedelta -# TODO in master -# The name of this class should be TestReconciliationHelpers -class TestReconciliation(AccountingTestCase): - - """Tests for reconciliation (account.tax) - - Test used to check that when doing a sale or purchase invoice in a different currency, - the result will be balanced. - """ - - @classmethod - def setUpClass(cls): - super(TestReconciliation, cls).setUpClass() - cls.company = cls.env['res.company'].create({ - 'name': 'A test company', - 'currency_id': cls.env.ref('base.EUR').id - }) - cls.env.user.company_id = cls.company - # Generate minimal data for my new company - cls.create_accounting_minimal_data() - - cls.acc_bank_stmt_model = cls.env['account.bank.statement'] - cls.acc_bank_stmt_line_model = cls.env['account.bank.statement.line'] - cls.res_currency_model = cls.registry('res.currency') - cls.res_currency_rate_model = cls.registry('res.currency.rate') - - cls.partner_agrolait = cls.env['res.partner'].create({ - 'name': 'Deco Addict', - 'is_company': True, - 'country_id': cls.env.ref('base.us').id, - }) - cls.partner_agrolait_id = cls.partner_agrolait.id - cls.currency_swiss_id = cls.env.ref("base.CHF").id - cls.currency_usd_id = cls.env.ref("base.USD").id - cls.currency_euro_id = cls.env.ref("base.EUR").id - # YTI FIXME Some of those lines should be useless now - cls.cr.execute("UPDATE res_company SET currency_id = %s WHERE id = %s", [cls.currency_euro_id, cls.company.id]) - cls.account_rcv = cls.partner_agrolait.property_account_receivable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_receivable').id)], limit=1) - cls.account_rsa = cls.partner_agrolait.property_account_payable_id or cls.env['account.account'].search([('user_type_id', '=', cls.env.ref('account.data_account_type_payable').id)], limit=1) - cls.product = cls.env['product.product'].create({ - 'name': 'Product Product 4', - 'standard_price': 500.0, - 'list_price': 750.0, - 'type': 'consu', - 'categ_id': cls.env.ref('product.product_category_all').id, - }) - - cls.bank_journal_euro = cls.env['account.journal'].create({'name': 'Bank', 'type': 'bank', 'code': 'BNK67'}) - cls.account_euro = cls.bank_journal_euro.default_debit_account_id - - cls.bank_journal_usd = cls.env['account.journal'].create({'name': 'Bank US', 'type': 'bank', 'code': 'BNK68', 'currency_id': cls.currency_usd_id}) - cls.account_usd = cls.bank_journal_usd.default_debit_account_id - - cls.fx_journal = cls.env['res.users'].browse(cls.env.uid).company_id.currency_exchange_journal_id - cls.diff_income_account = cls.env['res.users'].browse(cls.env.uid).company_id.income_currency_exchange_account_id - cls.diff_expense_account = cls.env['res.users'].browse(cls.env.uid).company_id.expense_currency_exchange_account_id - - cls.inbound_payment_method = cls.env['account.payment.method'].create({ - 'name': 'inbound', - 'code': 'IN', - 'payment_type': 'inbound', - }) - - cls.expense_account = cls.env['account.account'].create({ - 'name': 'EXP', - 'code': 'EXP', - 'user_type_id': cls.env.ref('account.data_account_type_expenses').id, - 'company_id': cls.company.id, - }) - # cash basis intermediary account - cls.tax_waiting_account = cls.env['account.account'].create({ - 'name': 'TAX_WAIT', - 'code': 'TWAIT', - 'user_type_id': cls.env.ref('account.data_account_type_current_liabilities').id, - 'reconcile': True, - 'company_id': cls.company.id, - }) - # cash basis final account - cls.tax_final_account = cls.env['account.account'].create({ - 'name': 'TAX_TO_DEDUCT', - 'code': 'TDEDUCT', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - 'company_id': cls.company.id, - }) - cls.tax_base_amount_account = cls.env['account.account'].create({ - 'name': 'TAX_BASE', - 'code': 'TBASE', - 'user_type_id': cls.env.ref('account.data_account_type_current_assets').id, - 'company_id': cls.company.id, - }) - - # Journals - cls.purchase_journal = cls.env['account.journal'].create({ - 'name': 'purchase', - 'code': 'PURCH', - 'type': 'purchase', - 'default_credit_account_id': cls.a_expense.id, - 'default_debit_account_id': cls.a_expense.id, - }) - cls.cash_basis_journal = cls.env['account.journal'].create({ - 'name': 'CABA', - 'code': 'CABA', - 'type': 'general', - }) - cls.general_journal = cls.env['account.journal'].create({ - 'name': 'general', - 'code': 'GENE', - 'type': 'general', - }) - - # Tax Cash Basis - cls.tax_cash_basis = cls.env['account.tax'].create({ - 'name': 'cash basis 20%', - 'type_tax_use': 'purchase', - 'company_id': cls.company.id, - 'amount': 20, - 'tax_exigibility': 'on_payment', - 'cash_basis_transition_account_id': cls.tax_waiting_account.id, - 'cash_basis_base_account_id': cls.tax_base_amount_account.id, - 'invoice_repartition_line_ids': [ - (0,0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - - (0,0, { - 'factor_percent': 100, - 'repartition_type': 'tax', - 'account_id': cls.tax_final_account.id, - }), - ], - 'refund_repartition_line_ids': [ - (0,0, { - 'factor_percent': 100, - 'repartition_type': 'base', - }), - - (0,0, { - 'factor_percent': 100, - 'repartition_type': 'tax', - 'account_id': cls.tax_final_account.id, - }), - ], - }) - cls.env['res.currency.rate'].create([ - { - 'currency_id': cls.env.ref('base.EUR').id, - 'name': '2010-01-02', - 'rate': 1.0, - }, { - 'currency_id': cls.env.ref('base.USD').id, - 'name': '2010-01-02', - 'rate': 1.2834, - }, { - 'currency_id': cls.env.ref('base.USD').id, - 'name': time.strftime('%Y-06-05'), - 'rate': 1.5289, - } - ]) - - def _create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None, partner_id=None, date_invoice=None, payment_term_id=False, auto_validate=False): - date_invoice = date_invoice or time.strftime('%Y') + '-07-01' - - invoice_vals = { - 'type': type, - 'partner_id': partner_id or self.partner_agrolait_id, - 'invoice_date': date_invoice, - 'date': date_invoice, - 'invoice_line_ids': [(0, 0, { - 'name': 'product that cost %s' % invoice_amount, - 'quantity': 1, - 'price_unit': invoice_amount, - 'tax_ids': [(6, 0, [])], - })] - } - - if payment_term_id: - invoice_vals['invoice_payment_term_id'] = payment_term_id - - if currency_id: - invoice_vals['currency_id'] = currency_id - - invoice = self.env['account.move'].with_context(default_type=type).create(invoice_vals) - if auto_validate: - invoice.post() - return invoice - - def create_invoice(self, type='out_invoice', invoice_amount=50, currency_id=None): - return self._create_invoice(type=type, invoice_amount=invoice_amount, currency_id=currency_id, auto_validate=True) - - def create_invoice_partner(self, type='out_invoice', invoice_amount=50, currency_id=None, partner_id=False, payment_term_id=False): - return self._create_invoice( - type=type, - invoice_amount=invoice_amount, - currency_id=currency_id, - partner_id=partner_id, - payment_term_id=payment_term_id, - auto_validate=True - ) - - def make_payment(self, invoice_record, bank_journal, amount=0.0, amount_currency=0.0, currency_id=None): - bank_stmt = self.acc_bank_stmt_model.create({ - 'journal_id': bank_journal.id, - 'date': time.strftime('%Y') + '-07-15', - 'name': 'payment' + invoice_record.name - }) - - bank_stmt_line = self.acc_bank_stmt_line_model.create({'name': 'payment', - 'statement_id': bank_stmt.id, - 'partner_id': self.partner_agrolait_id, - 'amount': amount, - 'amount_currency': amount_currency, - 'currency_id': currency_id, - 'date': time.strftime('%Y') + '-07-15', - }) - line_id = invoice_record.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable')) - amount_in_widget = currency_id and amount_currency or amount - bank_stmt_line.process_reconciliation(counterpart_aml_dicts=[{ - 'move_line': line_id, - 'debit': amount_in_widget < 0 and -amount_in_widget or 0.0, - 'credit': amount_in_widget > 0 and amount_in_widget or 0.0, - 'name': line_id.name, - }]) - return bank_stmt - - def make_customer_and_supplier_flows(self, invoice_currency_id, invoice_amount, bank_journal, amount, amount_currency, transaction_currency_id): - #we create an invoice in given invoice_currency - invoice_record = self.create_invoice(type='out_invoice', invoice_amount=invoice_amount, currency_id=invoice_currency_id) - #we encode a payment on it, on the given bank_journal with amount, amount_currency and transaction_currency given - bank_stmt = self.make_payment(invoice_record, bank_journal, amount=amount, amount_currency=amount_currency, currency_id=transaction_currency_id) - customer_move_lines = bank_stmt.move_line_ids - - #we create a supplier bill in given invoice_currency - invoice_record = self.create_invoice(type='in_invoice', invoice_amount=invoice_amount, currency_id=invoice_currency_id) - #we encode a payment on it, on the given bank_journal with amount, amount_currency and transaction_currency given - bank_stmt = self.make_payment(invoice_record, bank_journal, amount=-amount, amount_currency=-amount_currency, currency_id=transaction_currency_id) - supplier_move_lines = bank_stmt.move_line_ids - return customer_move_lines, supplier_move_lines +from odoo import api, fields +from odoo.addons.account.tests.common import TestAccountReconciliationCommon +from odoo.exceptions import UserError +from odoo.tests import Form, tagged @tagged('post_install', '-at_install') -class TestReconciliationExec(TestReconciliation): +class TestReconciliationExec(TestAccountReconciliationCommon): def test_statement_usd_invoice_eur_transaction_eur(self): customer_move_lines, supplier_move_lines = self.make_customer_and_supplier_flows(self.currency_euro_id, 30, self.bank_journal_usd, 42, 30, self.currency_euro_id) diff --git a/addons/account/tests/test_reconciliation_matching_rules.py b/addons/account/tests/test_reconciliation_matching_rules.py index 466f60c4131c..7ef983ae4d13 100644 --- a/addons/account/tests/test_reconciliation_matching_rules.py +++ b/addons/account/tests/test_reconciliation_matching_rules.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from odoo import fields, tools -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests.common import Form from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestReconciliationMatchingRules(AccountingTestCase): +class TestReconciliationMatchingRules(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/account/tests/test_search.py b/addons/account/tests/test_search.py index 5a80665558cf..b37e7e011f0e 100644 --- a/addons/account/tests/test_search.py +++ b/addons/account/tests/test_search.py @@ -1,9 +1,9 @@ -from odoo.addons.account.tests.account_test_users import AccountTestUsers +from odoo.addons.account.tests.common import AccountTestUsersCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestSearch(AccountTestUsers): +class TestSearch(AccountTestUsersCommon): """Tests for search on name_search (account.account) diff --git a/addons/account/tests/test_settings.py b/addons/account/tests/test_settings.py index e96b98349ac3..793cf71fe5a2 100644 --- a/addons/account/tests/test_settings.py +++ b/addons/account/tests/test_settings.py @@ -1,9 +1,9 @@ -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestSettings(AccountingTestCase): +class TestSettings(AccountTestCommon): def test_switch_taxB2B_taxB2C(self): """ diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index a9adc25cf7e8..9a0c51742c8e 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_users import AccountTestUsers +from odoo.addons.account.tests.common import AccountTestUsersCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestTax(AccountTestUsers): +class TestTax(AccountTestUsersCommon): @classmethod def setUpClass(cls): diff --git a/addons/account_check_printing/tests/test_print_check.py b/addons/account_check_printing/tests/test_print_check.py index 1b96aeab236a..3a47340a0c65 100644 --- a/addons/account_check_printing/tests/test_print_check.py +++ b/addons/account_check_printing/tests/test_print_check.py @@ -1,7 +1,7 @@ # Make sure / performs a floating point division even if environment is python 2 from __future__ import division -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.addons.account_check_printing.models.account_payment import INV_LINES_PER_STUB from odoo.tests import tagged from odoo.tests.common import Form @@ -11,7 +11,7 @@ import math @tagged('post_install', '-at_install') -class TestPrintCheck(AccountingTestCase): +class TestPrintCheck(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 73738a46fec9..a5fc9d91dfaa 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged, Form @tagged('post_install', '-at_install') -class StockMoveInvoice(AccountingTestCase): +class StockMoveInvoice(AccountTestCommon): def setUp(self): super(StockMoveInvoice, self).setUp() diff --git a/addons/hr_expense/tests/common.py b/addons/hr_expense/tests/common.py index b045a539a1a1..df35c8d3e75f 100644 --- a/addons/hr_expense/tests/common.py +++ b/addons/hr_expense/tests/common.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.account.tests.account_test_no_chart import TestAccountNoChartCommon +from odoo.addons.account.tests.common import AccountTestNoChartCommon -class TestExpenseCommon(TestAccountNoChartCommon): +class TestExpenseCommon(AccountTestNoChartCommon): @classmethod def setUpClass(cls): diff --git a/addons/l10n_ch/tests/test_l10n_ch_isr.py b/addons/l10n_ch/tests/test_l10n_ch_isr.py index 2a089dccd1de..dbd73bac1a03 100644 --- a/addons/l10n_ch/tests/test_l10n_ch_isr.py +++ b/addons/l10n_ch/tests/test_l10n_ch_isr.py @@ -3,13 +3,13 @@ import time -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.exceptions import ValidationError from odoo.tests import tagged @tagged('post_install', '-at_install') -class ISRTest(AccountingTestCase): +class ISRTest(AccountTestCommon): def create_invoice(self, currency_to_use='base.CHF'): """ Generates a test invoice """ diff --git a/addons/membership/tests/common.py b/addons/membership/tests/common.py index 2e8d889e58c2..77499230de70 100644 --- a/addons/membership/tests/common.py +++ b/addons/membership/tests/common.py @@ -3,10 +3,10 @@ import datetime from dateutil.relativedelta import relativedelta -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon -class TestMembershipCommon(AccountingTestCase): +class TestMembershipCommon(AccountTestCommon): def setUp(self): super(TestMembershipCommon, self).setUp() diff --git a/addons/payment/tests/common.py b/addons/payment/tests/common.py index 096c8e0eab36..58e12439cfb8 100644 --- a/addons/payment/tests/common.py +++ b/addons/payment/tests/common.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon -class PaymentAcquirerCommon(AccountingTestCase): +class PaymentAcquirerCommon(AccountTestCommon): def setUp(self): super(PaymentAcquirerCommon, self).setUp() diff --git a/addons/point_of_sale/tests/common.py b/addons/point_of_sale/tests/common.py index d9db5cf56208..cef2b387cdf9 100644 --- a/addons/point_of_sale/tests/common.py +++ b/addons/point_of_sale/tests/common.py @@ -2,12 +2,12 @@ from random import randint from odoo import fields, tools -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo.tests.common import SavepointCase, Form from odoo.tools import float_is_zero -class TestPointOfSaleCommon(StockAccountMinimalTest): +class TestPointOfSaleCommon(StockAccountTestCommon): @classmethod def setUpClass(cls): @@ -146,7 +146,7 @@ class TestPointOfSaleCommon(StockAccountMinimalTest): (invoice_rep_lines | refund_rep_lines).write({'account_id': cls.a_expense.id}) -class TestPoSCommon(StockAccountMinimalTest): +class TestPoSCommon(StockAccountTestCommon): """ Set common values for different special test cases. The idea is to set up common values here for the tests diff --git a/addons/point_of_sale/tests/test_pos_products_with_tax.py b/addons/point_of_sale/tests/test_pos_products_with_tax.py index a2f27b2b10a1..b0ef8ac873cd 100644 --- a/addons/point_of_sale/tests/test_pos_products_with_tax.py +++ b/addons/point_of_sale/tests/test_pos_products_with_tax.py @@ -190,7 +190,7 @@ class TestPoSProductsWithTax(TestPoSCommon): # check receivable line # should be equivalent to receivable in the invoice # should also be fully-reconciled - receivable_line = session_move.line_ids.filtered(lambda line: line.account_id in self.receivable_account + self.env['account.account'].search([('name', '=', 'Account Receivable (PoS)')]) and line.name == 'From invoiced orders') + receivable_line = session_move.line_ids.filtered(lambda line: line.account_id in self.receivable_account + self.env['account.account'].search([('name', '=', 'Account Receivable')]) and line.name == 'From invoiced orders') self.assertAlmostEqual(receivable_line.balance, -426.09) self.assertTrue(receivable_line.full_reconcile_id, msg='Receivable line for invoices should be fully reconciled.') diff --git a/addons/product_margin/tests/test_product_margin.py b/addons/product_margin/tests/test_product_margin.py index dc3f8a32bd9c..6bcca596b4a4 100644 --- a/addons/product_margin/tests/test_product_margin.py +++ b/addons/product_margin/tests/test_product_margin.py @@ -2,12 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import tools -from odoo.addons.account.tests.account_minimal_test import AccountMinimalTest +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import Form from odoo.modules.module import get_resource_path -class TestProductMargin(AccountMinimalTest): +class TestProductMargin(AccountTestCommon): def create_account_invoice(self, invoice_type, partner, product, quantity=0.0, price_unit=0.0): """ Create an invoice as in a view by triggering its onchange methods""" diff --git a/addons/purchase/tests/test_purchase_order_report.py b/addons/purchase/tests/test_purchase_order_report.py index 8d157f3ace1f..82fe92cefdae 100644 --- a/addons/purchase/tests/test_purchase_order_report.py +++ b/addons/purchase/tests/test_purchase_order_report.py @@ -3,10 +3,10 @@ from datetime import datetime from odoo.tests import Form, tagged -from odoo.addons.account.tests.account_minimal_test import AccountMinimalTest +from odoo.addons.account.tests.common import AccountTestCommon @tagged('post_install', '-at_install') -class TestPurchaseOrderReport(AccountMinimalTest): +class TestPurchaseOrderReport(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py index c65721fa8f15..01554c629056 100644 --- a/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/purchase_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -5,12 +5,12 @@ from datetime import datetime import time -from odoo.addons.stock_account.tests.test_anglo_saxon_valuation_reconciliation_common import ValuationReconciliationTestCase +from odoo.addons.stock_account.tests.test_anglo_saxon_valuation_reconciliation_common import ValuationReconciliationTestCommon from odoo.tests.common import Form, tagged @tagged('post_install', '-at_install') -class TestValuationReconciliation(ValuationReconciliationTestCase): +class TestValuationReconciliation(ValuationReconciliationTestCommon): def setUp(self): super(TestValuationReconciliation, self).setUp() diff --git a/addons/purchase_stock/tests/test_average_price.py b/addons/purchase_stock/tests/test_average_price.py index 07f0a27dd6df..099f8616bd91 100644 --- a/addons/purchase_stock/tests/test_average_price.py +++ b/addons/purchase_stock/tests/test_average_price.py @@ -4,9 +4,9 @@ import time from .common import TestPurchase -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon -class TestAveragePrice(TestPurchase, StockAccountMinimalTest): +class TestAveragePrice(TestPurchase, StockAccountTestCommon): def test_00_average_price(self): """ Testcase for average price computation""" diff --git a/addons/purchase_stock/tests/test_fifo_price.py b/addons/purchase_stock/tests/test_fifo_price.py index bea7347575ed..c683394f650f 100644 --- a/addons/purchase_stock/tests/test_fifo_price.py +++ b/addons/purchase_stock/tests/test_fifo_price.py @@ -3,9 +3,9 @@ import time from .common import TestPurchase -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon -class TestFifoPrice(TestPurchase, StockAccountMinimalTest): +class TestFifoPrice(TestPurchase, StockAccountTestCommon): def test_00_test_fifo(self): """ Test product cost price with fifo removal strategy.""" diff --git a/addons/purchase_stock/tests/test_fifo_returns.py b/addons/purchase_stock/tests/test_fifo_returns.py index d20835111cb7..c90e18b35c5d 100644 --- a/addons/purchase_stock/tests/test_fifo_returns.py +++ b/addons/purchase_stock/tests/test_fifo_returns.py @@ -4,10 +4,10 @@ import time from .common import TestPurchase from odoo.tests.common import Form -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon -class TestFifoReturns(TestPurchase, StockAccountMinimalTest): +class TestFifoReturns(TestPurchase, StockAccountTestCommon): def test_fifo_returns(self): """Test to create product and purchase order to test the FIFO returns of the product""" diff --git a/addons/purchase_stock/tests/test_purchase_order.py b/addons/purchase_stock/tests/test_purchase_order.py index 9358da80959b..09b0c934714e 100644 --- a/addons/purchase_stock/tests/test_purchase_order.py +++ b/addons/purchase_stock/tests/test_purchase_order.py @@ -4,12 +4,12 @@ from datetime import datetime from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import Form, tagged @tagged('post_install', '-at_install') -class TestPurchaseOrder(AccountingTestCase): +class TestPurchaseOrder(AccountTestCommon): def setUp(self): super(TestPurchaseOrder, self).setUp() diff --git a/addons/purchase_stock/tests/test_stockvaluation.py b/addons/purchase_stock/tests/test_stockvaluation.py index a8622746f931..61f21aed73d3 100644 --- a/addons/purchase_stock/tests/test_stockvaluation.py +++ b/addons/purchase_stock/tests/test_stockvaluation.py @@ -8,7 +8,7 @@ from unittest.mock import patch from odoo import fields from odoo.tests import Form from odoo.tests.common import TransactionCase, tagged -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT @@ -290,7 +290,7 @@ class TestStockValuation(TransactionCase): @tagged('post_install', '-at_install') -class TestStockValuationWithCOA(AccountingTestCase): +class TestStockValuationWithCOA(AccountTestCommon): def setUp(self): super(TestStockValuationWithCOA, self).setUp() self.supplier_location = self.env.ref('stock.stock_location_suppliers') diff --git a/addons/repair/tests/test_repair.py b/addons/repair/tests/test_repair.py index a144de379725..710282841201 100644 --- a/addons/repair/tests/test_repair.py +++ b/addons/repair/tests/test_repair.py @@ -3,12 +3,12 @@ from datetime import datetime -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestRepair(AccountingTestCase): +class TestRepair(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/sale/tests/test_sale_common.py b/addons/sale/tests/test_sale_common.py index 2973f3b74ebc..3d3520683c95 100644 --- a/addons/sale/tests/test_sale_common.py +++ b/addons/sale/tests/test_sale_common.py @@ -2,11 +2,11 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from collections import OrderedDict -from odoo.addons.account.tests.account_test_classes import AccountingTestCase -from odoo.addons.account.tests.account_test_no_chart import TestAccountNoChartCommon +from odoo.addons.account.tests.common import AccountTestCommon +from odoo.addons.account.tests.common import AccountTestNoChartCommon -class TestSale(AccountingTestCase): +class TestSale(AccountTestCommon): @classmethod def setUpClass(cls): @@ -89,11 +89,11 @@ class TestSale(AccountingTestCase): cls.partner = cls.env['res.partner'].create({'name': 'A test Partner'}) -class TestCommonSaleNoChart(TestAccountNoChartCommon): +class TestCommonSaleNoChart(AccountTestNoChartCommon): """ This class should be extended for test suite of sale flows with a minimal chart of accounting installed. This test suite should be executed at module installation. This class provides some method to generate testing data well configured, according to the minimal - chart of account, defined in `TestAccountNoChartCommon` class. + chart of account, defined in `AccountTestNoChartCommon` class. """ @classmethod diff --git a/addons/sale/tests/test_sale_transaction.py b/addons/sale/tests/test_sale_transaction.py index 3e33b2ea5bac..400bffec5c81 100644 --- a/addons/sale/tests/test_sale_transaction.py +++ b/addons/sale/tests/test_sale_transaction.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from odoo import tests -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon @tests.tagged('post_install', '-at_install') -class TestSaleTransaction(AccountingTestCase): +class TestSaleTransaction(AccountTestCommon): def test_sale_invoicing_from_transaction(self): ''' Test the following scenario: - Create a sale order diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index 18c7073dcf9a..0cfcaf379de1 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.account.tests.account_minimal_test import AccountMinimalTest +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import common, Form from odoo.exceptions import UserError from odoo.tools import mute_logger, float_compare @@ -9,7 +9,7 @@ from odoo.tools import mute_logger, float_compare # these tests create accounting entries, and therefore need a chart of accounts @common.tagged('post_install', '-at_install') -class TestSaleMrpFlow(AccountMinimalTest): +class TestSaleMrpFlow(AccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py index 372cb0c72b14..038990def818 100644 --- a/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py +++ b/addons/sale_stock/tests/test_anglo_saxon_valuation_reconciliation.py @@ -3,12 +3,12 @@ import time -from odoo.addons.stock_account.tests.test_anglo_saxon_valuation_reconciliation_common import ValuationReconciliationTestCase +from odoo.addons.stock_account.tests.test_anglo_saxon_valuation_reconciliation_common import ValuationReconciliationTestCommon from odoo.tests import Form, tagged @tagged('post_install', '-at_install') -class TestValuationReconciliation(ValuationReconciliationTestCase): +class TestValuationReconciliation(ValuationReconciliationTestCommon): def setUp(self): super(TestValuationReconciliation, self).setUp() diff --git a/addons/snailmail_account/tests/test_pingen_send.py b/addons/snailmail_account/tests/test_pingen_send.py index ea4cd973487b..19d0738a89f7 100644 --- a/addons/snailmail_account/tests/test_pingen_send.py +++ b/addons/snailmail_account/tests/test_pingen_send.py @@ -4,13 +4,13 @@ import json import base64 import logging -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.tests import tagged _logger = logging.getLogger(__name__) @tagged('post_install', '-at_install', '-standard', 'external') -class TestPingenSend(AccountingTestCase): +class TestPingenSend(AccountTestCommon): def setUp(self): super(TestPingenSend, self).setUp() diff --git a/addons/stock_account/tests/stock_account_minimal_test.py b/addons/stock_account/tests/common.py similarity index 83% rename from addons/stock_account/tests/stock_account_minimal_test.py rename to addons/stock_account/tests/common.py index a93d6f14c145..ae153a77cb1c 100644 --- a/addons/stock_account/tests/stock_account_minimal_test.py +++ b/addons/stock_account/tests/common.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon -class StockAccountMinimalTest(AccountingTestCase): +class StockAccountTestCommon(AccountTestCommon): @classmethod def setUpClass(cls): - super(StockAccountMinimalTest, cls).setUpClass() + super(StockAccountTestCommon, cls).setUpClass() # Properties: Stock valuation account and journal cls.env['ir.property'].create([{ diff --git a/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py b/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py index 3fbe09aa9d60..87109bece041 100644 --- a/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py +++ b/addons/stock_account/tests/test_anglo_saxon_valuation_reconciliation_common.py @@ -2,10 +2,10 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo import fields -class ValuationReconciliationTestCase(StockAccountMinimalTest): +class ValuationReconciliationTestCommon(StockAccountTestCommon): """ Base class for tests checking interim accounts reconciliation works in anglosaxon accounting. It sets up everything we need in the tests, and is extended in both sale_stock and purchase modules to run the 'true' tests. @@ -60,7 +60,7 @@ class ValuationReconciliationTestCase(StockAccountMinimalTest): }) def setUp(self): - super(ValuationReconciliationTestCase, self).setUp() + super(ValuationReconciliationTestCommon, self).setUp() self.company = self.env.company self.company.anglo_saxon_accounting = True diff --git a/addons/stock_dropshipping/tests/test_lifo_price.py b/addons/stock_dropshipping/tests/test_lifo_price.py index 5edf4059bb8c..5dd28152a465 100644 --- a/addons/stock_dropshipping/tests/test_lifo_price.py +++ b/addons/stock_dropshipping/tests/test_lifo_price.py @@ -2,12 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import fields, tools -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo.modules.module import get_module_resource from odoo.tests import common, Form -class TestLifoPrice(StockAccountMinimalTest): +class TestLifoPrice(StockAccountTestCommon): def test_lifoprice(self): diff --git a/addons/stock_dropshipping/tests/test_stockvaluation.py b/addons/stock_dropshipping/tests/test_stockvaluation.py index d4805cca50b6..59c834a89628 100644 --- a/addons/stock_dropshipping/tests/test_stockvaluation.py +++ b/addons/stock_dropshipping/tests/test_stockvaluation.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo.tests import Form, tagged @tagged('post_install', '-at_install') -class TestStockValuation(StockAccountMinimalTest): +class TestStockValuation(StockAccountTestCommon): @classmethod def setUpClass(cls): diff --git a/addons/stock_landed_costs/tests/common.py b/addons/stock_landed_costs/tests/common.py index 273d1a246fd4..52b540fe64c0 100644 --- a/addons/stock_landed_costs/tests/common.py +++ b/addons/stock_landed_costs/tests/common.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- from odoo import tools -from odoo.addons.account.tests.account_test_classes import AccountingTestCase +from odoo.addons.account.tests.common import AccountTestCommon from odoo.modules.module import get_module_resource -class TestStockLandedCostsCommon(AccountingTestCase): +class TestStockLandedCostsCommon(AccountTestCommon): def setUp(self): super(TestStockLandedCostsCommon, self).setUp() diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs.py b/addons/stock_landed_costs/tests/test_stock_landed_costs.py index fd366173e4b4..708f0aaedbc6 100644 --- a/addons/stock_landed_costs/tests/test_stock_landed_costs.py +++ b/addons/stock_landed_costs/tests/test_stock_landed_costs.py @@ -2,13 +2,13 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.stock_landed_costs.tests.common import TestStockLandedCostsCommon -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo.exceptions import ValidationError from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountMinimalTest): +class TestStockLandedCosts(TestStockLandedCostsCommon, StockAccountTestCommon): def test_stock_landed_costs(self): # In order to test the landed costs feature of stock, diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py b/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py index 458a9791e68d..9f4a6af49bc1 100644 --- a/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py +++ b/addons/stock_landed_costs/tests/test_stock_landed_costs_rounding.py @@ -2,12 +2,12 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.stock_landed_costs.tests.common import TestStockLandedCostsCommon -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon from odoo.tests import tagged @tagged('post_install', '-at_install') -class TestStockLandedCostsRounding(TestStockLandedCostsCommon, StockAccountMinimalTest): +class TestStockLandedCostsRounding(TestStockLandedCostsCommon, StockAccountTestCommon): def test_stock_landed_costs_rounding(self): # In order to test the rounding in landed costs feature of stock, I create 2 landed cost diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py index 66c075858d73..96d9763608b7 100644 --- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py +++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py @@ -6,10 +6,10 @@ from odoo.tests import Form, tagged from odoo.addons.stock_account.tests.test_stockvaluationlayer import TestStockValuationCommon from odoo.addons.stock_account.tests.test_stockvaluation import _create_accounting_data -from odoo.addons.stock_account.tests.stock_account_minimal_test import StockAccountMinimalTest +from odoo.addons.stock_account.tests.common import StockAccountTestCommon -class TestStockValuationLC(TestStockValuationCommon, StockAccountMinimalTest): +class TestStockValuationLC(TestStockValuationCommon, StockAccountTestCommon): @classmethod def setUpClass(cls): super(TestStockValuationLC, cls).setUpClass() -- GitLab