diff --git a/account_financial_report/tests/test_age_report_configuration.py b/account_financial_report/tests/test_age_report_configuration.py index 4142e1eacc4..84370c1ef03 100644 --- a/account_financial_report/tests/test_age_report_configuration.py +++ b/account_financial_report/tests/test_age_report_configuration.py @@ -1,12 +1,14 @@ # Copyright 2023 Tecnativa - Carolina Fernandez # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - +from odoo import Command from odoo.exceptions import ValidationError -from odoo.tests import common, tagged +from odoo.tests import tagged + +from odoo.addons.base.tests.common import BaseCommon @tagged("post_install", "-at_install") -class TestAccountAgeReportConfiguration(common.TransactionCase): +class TestAccountAgeReportConfiguration(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() @@ -16,9 +18,7 @@ def setUpClass(cls): { "name": "Intervals configuration", "line_ids": [ - ( - 0, - 0, + Command.create( { "name": "1-30", "inferior_limit": 30, diff --git a/account_financial_report/tests/test_aged_partner_balance.py b/account_financial_report/tests/test_aged_partner_balance.py index 9f3d0906dec..fcd3f1757a3 100644 --- a/account_financial_report/tests/test_aged_partner_balance.py +++ b/account_financial_report/tests/test_aged_partner_balance.py @@ -1,25 +1,18 @@ # Copyright 2021 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests import TransactionCase, tagged +from odoo import Command +from odoo.tests import tagged from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, test_reports +from odoo.addons.base.tests.common import BaseCommon + @tagged("post_install", "-at_install") -class TestAgedPartnerBalance(TransactionCase): +class TestAgedPartnerBalance(BaseCommon): @classmethod def setUpClass(cls): super().setUpClass() - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) cls.wizard_model = cls.env["aged.partner.balance.report.wizard"] # Check that report is produced correctly cls.wizard_with_line_details = cls.wizard_model.create( @@ -40,9 +33,7 @@ def setUpClass(cls): { "name": "Intervals configuration", "line_ids": [ - ( - 0, - 0, + Command.create( { "name": "1-30", "inferior_limit": 30, diff --git a/account_financial_report/tests/test_general_ledger.py b/account_financial_report/tests/test_general_ledger.py index 2e9187bc46a..de176119ac4 100644 --- a/account_financial_report/tests/test_general_ledger.py +++ b/account_financial_report/tests/test_general_ledger.py @@ -6,8 +6,9 @@ import time from datetime import date -from odoo import api, fields +from odoo import Command, api, fields from odoo.tests import tagged +from odoo.tools import mute_logger from odoo.addons.account.tests.common import AccountTestInvoicingCommon @@ -15,18 +16,8 @@ @tagged("post_install", "-at_install") class TestGeneralLedgerReport(AccountTestInvoicingCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) + def setUpClass(cls): + super().setUpClass() cls.before_previous_fy_year = fields.Date.from_string("2014-05-05") cls.previous_fy_date_start = fields.Date.from_string("2015-01-01") cls.previous_fy_date_end = fields.Date.from_string("2015-12-31") @@ -66,9 +57,7 @@ def _add_move( "journal_id": journal.id, "date": date, "line_ids": [ - ( - 0, - 0, + Command.create( { "debit": receivable_debit, "credit": receivable_credit, @@ -76,9 +65,7 @@ def _add_move( "partner_id": partner.id, }, ), - ( - 0, - 0, + Command.create( { "debit": income_debit, "credit": income_credit, @@ -86,9 +73,7 @@ def _add_move( "partner_id": partner.id, }, ), - ( - 0, - 0, + Command.create( { "debit": unaffected_debit, "credit": unaffected_credit, @@ -687,6 +672,7 @@ def test_04_unaffected_account_balance_2_years(self): self.assertEqual(unaffected_fin_balance["credit"], 1000) self.assertEqual(unaffected_fin_balance["balance"], 500) + @mute_logger("odoo.models.unlink") def test_partner_filter(self): partner_1 = self.env.ref("base.res_partner_1") partner_2 = self.env.ref("base.res_partner_2") diff --git a/account_financial_report/tests/test_journal_ledger.py b/account_financial_report/tests/test_journal_ledger.py index bd34393221f..757c515269d 100644 --- a/account_financial_report/tests/test_journal_ledger.py +++ b/account_financial_report/tests/test_journal_ledger.py @@ -6,7 +6,7 @@ from dateutil.relativedelta import relativedelta -from odoo.fields import Date +from odoo.fields import Command, Date from odoo.tests import tagged from odoo.tests.common import Form @@ -16,18 +16,8 @@ @tagged("post_install", "-at_install") class TestJournalReport(AccountTestInvoicingCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) + def setUpClass(cls): + super().setUpClass() cls.AccountObj = cls.env["account.account"] cls.InvoiceObj = cls.env["account.move"] cls.JournalObj = cls.env["account.journal"] @@ -100,9 +90,7 @@ def _add_move( "journal_id": journal.id, "date": date, "line_ids": [ - ( - 0, - 0, + Command.create( { "name": move_name, "debit": receivable_debit, @@ -110,9 +98,7 @@ def _add_move( "account_id": self.receivable_account.id, }, ), - ( - 0, - 0, + Command.create( { "name": move_name, "debit": income_debit, @@ -173,7 +159,7 @@ def test_01_test_total(self): "date_from": self.fy_date_start, "date_to": self.fy_date_end, "company_id": self.company.id, - "journal_ids": [(6, 0, self.journal_sale.ids)], + "journal_ids": [Command.set(self.journal_sale.ids)], "move_target": "all", } ) @@ -234,7 +220,7 @@ def test_02_test_taxes_out_invoice(self): "date_from": self.fy_date_start, "date_to": self.fy_date_end, "company_id": self.company.id, - "journal_ids": [(6, 0, self.journal_sale.ids)], + "journal_ids": [Command.set(self.journal_sale.ids)], "move_target": "all", } ) @@ -272,7 +258,7 @@ def test_03_test_taxes_in_invoice(self): "date_from": self.fy_date_start, "date_to": self.fy_date_end, "company_id": self.company.id, - "journal_ids": [(6, 0, self.journal_purchase.ids)], + "journal_ids": [Command.set(self.journal_purchase.ids)], "move_target": "all", } ) diff --git a/account_financial_report/tests/test_open_items.py b/account_financial_report/tests/test_open_items.py index 532d896e022..3d6c3e7bbb6 100644 --- a/account_financial_report/tests/test_open_items.py +++ b/account_financial_report/tests/test_open_items.py @@ -3,26 +3,14 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.tests import tagged +from odoo.tools import mute_logger from odoo.addons.account.tests.common import AccountTestInvoicingCommon @tagged("post_install", "-at_install") class TestOpenItems(AccountTestInvoicingCommon): - @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) - + @mute_logger("odoo.models.unlink") def test_partner_filter(self): partner_1 = self.env.ref("base.res_partner_1") partner_2 = self.env.ref("base.res_partner_2") diff --git a/account_financial_report/tests/test_trial_balance.py b/account_financial_report/tests/test_trial_balance.py index 7226a54bdcd..42a5ecedc14 100644 --- a/account_financial_report/tests/test_trial_balance.py +++ b/account_financial_report/tests/test_trial_balance.py @@ -3,6 +3,7 @@ # Copyright 2020 ForgeFlow S.L. (https://www.forgeflow.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.fields import Command from odoo.tests import tagged from odoo.addons.account.tests.common import AccountTestInvoicingCommon @@ -11,18 +12,8 @@ @tagged("post_install", "-at_install") class TestTrialBalanceReport(AccountTestInvoicingCommon): @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) + def setUpClass(cls): + super().setUpClass() # Remove previous account groups and related invoices to avoid conflicts group_obj = cls.env["account.group"] cls.group1 = group_obj.create({"code_prefix_start": "1", "name": "Group 1"}) @@ -120,9 +111,7 @@ def _add_move( "journal_id": journal.id, "date": date, "line_ids": [ - ( - 0, - 0, + Command.create( { "debit": receivable_debit, "credit": receivable_credit, @@ -130,9 +119,7 @@ def _add_move( "account_id": self.account100.id, }, ), - ( - 0, - 0, + Command.create( { "debit": income_debit, "credit": income_credit, @@ -140,9 +127,7 @@ def _add_move( "account_id": self.account200.id, }, ), - ( - 0, - 0, + Command.create( { "debit": unaffected_debit, "credit": unaffected_credit, @@ -150,9 +135,7 @@ def _add_move( "account_id": self.account110.id, }, ), - ( - 0, - 0, + Command.create( { "debit": receivable_debit, "credit": receivable_credit, @@ -160,9 +143,7 @@ def _add_move( "account_id": self.account300.id, }, ), - ( - 0, - 0, + Command.create( { "debit": receivable_credit, "credit": receivable_debit, @@ -520,14 +501,10 @@ def test_04_undistributed_pl(self): "journal_id": journal.id, "date": self.previous_fy_date_end, "line_ids": [ - ( - 0, - 0, + Command.create( {"debit": 0.0, "credit": 1000.0, "account_id": self.account300.id}, ), - ( - 0, - 0, + Command.create( {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], @@ -574,14 +551,10 @@ def test_04_undistributed_pl(self): "journal_id": journal.id, "date": self.date_start, "line_ids": [ - ( - 0, - 0, + Command.create( {"debit": 0.0, "credit": 1000.0, "account_id": self.account300.id}, ), - ( - 0, - 0, + Command.create( {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], @@ -628,14 +601,10 @@ def test_04_undistributed_pl(self): "journal_id": journal.id, "date": self.date_start, "line_ids": [ - ( - 0, - 0, + Command.create( {"debit": 0.0, "credit": 1000.0, "account_id": self.account110.id}, ), - ( - 0, - 0, + Command.create( {"debit": 1000.0, "credit": 0.0, "account_id": self.account100.id}, ), ], diff --git a/account_financial_report/tests/test_vat_report.py b/account_financial_report/tests/test_vat_report.py index 04cb9a5b261..649cca6363e 100644 --- a/account_financial_report/tests/test_vat_report.py +++ b/account_financial_report/tests/test_vat_report.py @@ -6,6 +6,7 @@ from datetime import date from odoo import fields +from odoo.fields import Command from odoo.tests import tagged from odoo.tests.common import Form @@ -47,18 +48,8 @@ def init_invoice( return rslt @classmethod - def setUpClass(cls, chart_template_ref=None): - super().setUpClass(chart_template_ref=chart_template_ref) - cls.env = cls.env( - context=dict( - cls.env.context, - mail_create_nolog=True, - mail_create_nosubscribe=True, - mail_notrack=True, - no_reset_password=True, - tracking_disable=True, - ) - ) + def setUpClass(cls): + super().setUpClass() cls.date_from = time.strftime("%Y-%m-01") cls.date_to = time.strftime("%Y-%m-28") cls.company = cls.env.user.company_id @@ -114,10 +105,8 @@ def setUpClass(cls, chart_template_ref=None): "company_id": cls.company.id, "tax_group_id": cls.tax_group_10.id, "invoice_repartition_line_ids": [ - (0, 0, {"factor_percent": 100, "repartition_type": "base"}), - ( - 0, - 0, + Command.create({"factor_percent": 100, "repartition_type": "base"}), + Command.create( { "factor_percent": 100, "repartition_type": "tax", @@ -127,10 +116,8 @@ def setUpClass(cls, chart_template_ref=None): ), ], "refund_repartition_line_ids": [ - (0, 0, {"factor_percent": 100, "repartition_type": "base"}), - ( - 0, - 0, + Command.create({"factor_percent": 100, "repartition_type": "base"}), + Command.create( { "factor_percent": 100, "repartition_type": "tax", @@ -151,10 +138,8 @@ def setUpClass(cls, chart_template_ref=None): "cash_basis_transition_account_id": cls.tax_account.id, "tax_group_id": cls.tax_group_20.id, "invoice_repartition_line_ids": [ - (0, 0, {"factor_percent": 100, "repartition_type": "base"}), - ( - 0, - 0, + Command.create({"factor_percent": 100, "repartition_type": "base"}), + Command.create( { "factor_percent": 100, "repartition_type": "tax", @@ -164,10 +149,8 @@ def setUpClass(cls, chart_template_ref=None): ), ], "refund_repartition_line_ids": [ - (0, 0, {"factor_percent": 100, "repartition_type": "base"}), - ( - 0, - 0, + Command.create({"factor_percent": 100, "repartition_type": "base"}), + Command.create( { "factor_percent": 100, "repartition_type": "tax",