Skip to content

Commit

Permalink
[IMP] account_ecotax : remove dependency on AccountTestInvoicingCommo…
Browse files Browse the repository at this point in the history
…n from tests

The dependency does not really ease the present test but forces us to put the test as post-installed which cant work as account_ecotax_tax changes the account_ecotax behavior
Instead of isolating the tests of account_ecotax, it seems better to get rid of the AccountTestInvoicingCommon dependency. It also speed up the tests.
  • Loading branch information
florian-dacosta committed Nov 20, 2024
1 parent 8bc3f4a commit 7e230c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
28 changes: 13 additions & 15 deletions account_ecotax/tests/test_ecotax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
from random import choice

from odoo import Command
from odoo.tests.common import Form, tagged
from odoo.tests.common import Form, TransactionCase

from odoo.addons.account.tests.common import AccountTestInvoicingCommon


class TestInvoiceEcotaxCommon(AccountTestInvoicingCommon):
class TestInvoiceEcotaxCommon(TransactionCase):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref)
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

# ACCOUNTING STUFF
Expand Down Expand Up @@ -105,15 +103,16 @@ def setUpClass(cls, chart_template_ref=None):
@classmethod
def _make_invoice(cls, products):
"""Creates a new customer invoice with given products and returns it"""
invoice = cls.init_invoice(
"out_invoice",
partner=cls.invoice_partner,
products=products,
company=cls.env.user.company_id,
taxes=cls.invoice_tax,
move_form = Form(
cls.env["account.move"].with_context(default_move_type="out_invoice")
)
invoice.invoice_line_ids._compute_tax_ids()
invoice.invoice_line_ids._compute_ecotax()
move_form.partner_id = cls.invoice_partner

for product in products or []:
with move_form.invoice_line_ids.new() as line_form:
line_form.product_id = product

invoice = move_form.save()
return invoice

@classmethod
Expand Down Expand Up @@ -407,7 +406,6 @@ def _test_05_product_variants(self):
)


@tagged("-at_install", "post_install")
class TestInvoiceEcotax(TestInvoiceEcotaxCommon):
def test_01_default_fixed_ecotax(self):
self._test_01_default_fixed_ecotax()
Expand Down
11 changes: 5 additions & 6 deletions account_ecotax_tax/tests/test_ecotax.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


from odoo.tests.common import tagged

from odoo.addons.account_ecotax.tests.test_ecotax import TestInvoiceEcotaxCommon


@tagged("-at_install", "post_install")
class TestInvoiceEcotaxTax(TestInvoiceEcotaxCommon):
class TestInvoiceEcotaxTaxComon(TestInvoiceEcotaxCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref)
def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))

# ACCOUNTING STUFF
Expand Down Expand Up @@ -134,6 +131,8 @@ def setUpClass(cls, chart_template_ref=None):
# 2- Weight-based ecotax
cls.ecotax_weight.sale_ecotax_ids = cls.invoice_weight_based_ecotax


class TestInvoiceEcotaxTax(TestInvoiceEcotaxTaxComon):
def test_01_default_fixed_ecotax(self):
self._test_01_default_fixed_ecotax()

Expand Down

0 comments on commit 7e230c6

Please sign in to comment.