From f34d8632572dfe8911b62471882eae60f6e6ae72 Mon Sep 17 00:00:00 2001 From: "Nicolas (vin)" Date: Thu, 31 Mar 2022 13:16:07 +0000 Subject: [PATCH] [FIX] account,*: Ensure tests using TestInvoicingCommon runs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a check in 'AccountTestInvoicingCommon' to ensure that all tests using it are run in post_install. These tests cannot be run at install, thus they would be ignored and wouldn't run on the Runbot. X-original-commit: 659ee179e1beed962026e3abac1bda322c2ac964 [FIX] account,*: Ensure tests using TestInvoicingCommon runs Add a check in 'AccountTestInvoicingCommon' to ensure that all tests using it are run in post_install. These tests cannot be run at install, thus they would be ignored and wouldn't run on the Runbot. closes odoo/odoo#90242 X-original-commit: ec36b403edda3fbe3b5bd5f30f31ef6bad680967 Related: odoo/enterprise#26791 Signed-off-by: Florian Gilbert Signed-off-by: William André (wan) --- addons/account/tests/common.py | 2 + addons/account_edi/tests/test_edi.py | 53 +------------------ .../tests/test_sepa_qr.py | 2 + .../tests/test_project_profitability.py | 3 ++ .../tests/test_so_line_milestones.py | 2 + addons/sale_timesheet/tests/test_project.py | 4 +- 6 files changed, 14 insertions(+), 52 deletions(-) diff --git a/addons/account/tests/common.py b/addons/account/tests/common.py index 7f01e6e8e31..3e486cd595a 100644 --- a/addons/account/tests/common.py +++ b/addons/account/tests/common.py @@ -30,6 +30,8 @@ class AccountTestInvoicingCommon(TransactionCase): def setUpClass(cls, chart_template_ref=None): super(AccountTestInvoicingCommon, cls).setUpClass() + assert 'post_install' in cls.test_tags, 'This test requires a CoA to be installed, it should be tagged "post_install"' + if chart_template_ref: chart_template = cls.env.ref(chart_template_ref) else: diff --git a/addons/account_edi/tests/test_edi.py b/addons/account_edi/tests/test_edi.py index d1177237f6a..b48a927adf5 100644 --- a/addons/account_edi/tests/test_edi.py +++ b/addons/account_edi/tests/test_edi.py @@ -5,8 +5,10 @@ from odoo import Command from odoo.addons.account_edi.tests.common import AccountEdiTestCommon, _mocked_post_two_steps, _generate_mocked_needs_web_services, _mocked_cancel_failed, _generate_mocked_support_batching from unittest.mock import patch from odoo.addons.base.tests.test_ir_cron import CronMixinCase +from odoo.tests import tagged +@tagged('post_install', '-at_install') class TestAccountEdi(AccountEdiTestCommon, CronMixinCase): @classmethod @@ -228,57 +230,6 @@ class TestAccountEdi(AccountEdiTestCommon, CronMixinCase): self.assertEqual(len(capt.records), 2, "Not all records have been processed in this run, the cron should " "re-trigger itself to process some more later") - def test_prepare_edi_vals_to_export(self): - """ - Test _prepare_edi_vals_to_export return values - in the proper format - - tag_ids should be a set of id and tags a proper recordset - """ - account_tag = self.env['account.account.tag'].create({ - "applicability": "taxes", - "country_id": self.env.ref('base.us').id, - "name": "Test Tag", - }) - tax = self.env['account.tax'].create({ - "amount": 15, - "amount_type": "percent", - "description": "15%", - "country_id": self.env.ref('base.us').id, - "invoice_repartition_line_ids": [ - Command.create({ - "factor_percent": 100, - "repartition_type": "base", - "sequence": 1, - }), - Command.create({ - "factor_percent": 100, - "repartition_type": "tax", - "sequence": 1, - "tag_ids": [Command.link(account_tag.id)] - }) - ], - "name": "Test", - "tax_exigibility": "on_invoice", - "type_tax_use": "sale" - }) - - invoices = self.env['account.move'].create({ - 'move_type': 'out_invoice', - 'invoice_date': '2019-01-01', - 'date': '2019-01-01', - 'partner_id': self.partner_a.id, - 'invoice_line_ids': [Command.create({ - 'product_id': self.product_a.id, - 'tax_ids': [Command.link(tax.id)] - })], - }) - vals = invoices._prepare_edi_vals_to_export() - self.assertEqual( - vals['invoice_line_vals_list'][0]['tax_detail_vals_list'][0]['tag_ids'], set(account_tag.ids)) - self.assertEqual( - vals['invoice_line_vals_list'][0]['tax_detail_vals_list'][0]['tags'].name, "Test Tag") - def test_invoice_ready_to_be_sent(self): def _is_needed_for_invoice(edi_format, invoice): return True diff --git a/addons/account_qr_code_sepa/tests/test_sepa_qr.py b/addons/account_qr_code_sepa/tests/test_sepa_qr.py index e9c1ce4af23..6322036c4e7 100644 --- a/addons/account_qr_code_sepa/tests/test_sepa_qr.py +++ b/addons/account_qr_code_sepa/tests/test_sepa_qr.py @@ -2,8 +2,10 @@ from odoo.exceptions import UserError from odoo.addons.account.tests.common import AccountTestInvoicingCommon +from odoo.tests import tagged +@tagged('post_install', '-at_install') class TestSEPAQRCode(AccountTestInvoicingCommon): """ Tests the generation of Swiss QR-codes on invoices """ diff --git a/addons/project_hr_expense/tests/test_project_profitability.py b/addons/project_hr_expense/tests/test_project_profitability.py index 6c4ed965e41..b90cee37b38 100644 --- a/addons/project_hr_expense/tests/test_project_profitability.py +++ b/addons/project_hr_expense/tests/test_project_profitability.py @@ -3,6 +3,7 @@ from odoo.addons.hr_expense.tests.common import TestExpenseCommon from odoo.addons.project.tests.test_project_profitability import TestProjectProfitabilityCommon +from odoo.tests.common import tagged class TestProjectHrExpenseProfitabilityCommon(TestExpenseCommon): @@ -30,6 +31,8 @@ class TestProjectHrExpenseProfitabilityCommon(TestExpenseCommon): self.assertEqual(expense_sheet.state, 'approve') return expense_sheet + +@tagged('post_install', '-at_install') class TestProjectHrExpenseProfitability(TestProjectProfitabilityCommon, TestProjectHrExpenseProfitabilityCommon): def test_project_profitability(self): diff --git a/addons/sale_project/tests/test_so_line_milestones.py b/addons/sale_project/tests/test_so_line_milestones.py index f5620d9c590..8b33b666592 100644 --- a/addons/sale_project/tests/test_so_line_milestones.py +++ b/addons/sale_project/tests/test_so_line_milestones.py @@ -2,8 +2,10 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo.addons.sale.tests.common import TestSaleCommon +from odoo.tests.common import tagged +@tagged('post_install', '-at_install') class TestSoLineMilestones(TestSaleCommon): @classmethod diff --git a/addons/sale_timesheet/tests/test_project.py b/addons/sale_timesheet/tests/test_project.py index e15bc9bd0b1..4da49202543 100644 --- a/addons/sale_timesheet/tests/test_project.py +++ b/addons/sale_timesheet/tests/test_project.py @@ -2,9 +2,11 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import Command - from .common import TestCommonSaleTimesheet +from odoo.tests import tagged + +@tagged('post_install', '-at_install') class TestProject(TestCommonSaleTimesheet): def test_fetch_sale_order_items(self): """ Test _fetch_sale_order_items and _get_sale_order_items methods