Skip to content

Commit 9d42c54

Browse files
committed
[MIG] account_ecotax_tax: Migration to 18.0
1 parent a350808 commit 9d42c54

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

account_ecotax_tax/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "Ecotax Management (with Odoo tax)",
66
"summary": "Use Odoo tax mechanism to compute the ecotaxes ",
7-
"version": "17.0.1.0.1",
7+
"version": "18.0.1.0.1",
88
"author": "Akretion, Odoo Community Association (OCA)",
99
"website": "https://github.com/OCA/account-fiscal-rule",
1010
"category": "Localization/Account Taxes",

account_ecotax_tax/models/account_tax.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,21 @@ def onchange_is_ecotax(self):
2222
if self.is_ecotax:
2323
self.amount_type = "code"
2424
self.include_base_amount = True
25-
self.python_compute = """
25+
self.formula = """
2626
# price_unit
2727
# product: product.product object or None
2828
# partner: res.partner object or None
29-
# for weight based ecotax
30-
# result = quantity and product.weight_based_ecotax * quantity or 0.0
31-
result = quantity and product.fixed_ecotax * quantity or 0.0
29+
# for weight based ecotax:
30+
# quantity and product.weight_based_ecotax * quantity or 0.0
31+
quantity and product.fixed_ecotax * quantity or 0.0
3232
"""
33+
34+
def _eval_taxes_computation_prepare_product_fields(self):
35+
# In Odoo 18, product is passed as a dictionary in the eval context.
36+
# We need to specify which fields should be included in this dictionary.
37+
return super()._eval_taxes_computation_prepare_product_fields() | {
38+
"fixed_ecotax",
39+
"weight_based_ecotax",
40+
"ecotax_amount",
41+
"weight",
42+
}

account_ecotax_tax/tests/test_ecotax.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,25 @@ def setUpClass(cls):
1515
# included with tax not included (B2B case)
1616
# Also for this version, the included use case using tax is broken because
1717
# of a bug in Odoo core (check readme)
18-
cls.invoice_tax.price_include = False
18+
cls.invoice_tax.price_include_override = "tax_excluded"
1919
cls.invoice_ecotax_account = cls.env["account.account"].create(
2020
{
2121
"code": "707120",
2222
"name": "Ecotax Account",
2323
"account_type": "income",
24-
"company_id": cls.env.user.company_id.id,
2524
}
2625
)
2726
cls.invoice_fixed_ecotax = cls.env["account.tax"].create(
2827
{
2928
"name": "Fixed Ecotax",
3029
"type_tax_use": "sale",
3130
"company_id": cls.env.user.company_id.id,
32-
"price_include": False,
31+
"price_include_override": "tax_excluded",
3332
"amount_type": "code",
3433
"include_base_amount": True,
3534
"sequence": 0,
3635
"is_ecotax": True,
37-
"python_compute": "result = (quantity and"
38-
" product.fixed_ecotax * quantity or 0.0)",
36+
"formula": "quantity and product.fixed_ecotax * quantity or 0.0",
3937
"tax_exigibility": "on_invoice",
4038
"invoice_repartition_line_ids": [
4139
(
@@ -84,11 +82,10 @@ def setUpClass(cls):
8482
"company_id": cls.env.user.company_id.id,
8583
"amount_type": "code",
8684
"include_base_amount": True,
87-
"price_include": False,
85+
"price_include_override": "tax_excluded",
8886
"sequence": 0,
8987
"is_ecotax": True,
90-
"python_compute": "result = (quantity and"
91-
" product.weight_based_ecotax * quantity or 0.0)",
88+
"formula": "quantity and product.weight_based_ecotax * quantity or 0.0",
9289
"tax_exigibility": "on_invoice",
9390
"invoice_repartition_line_ids": [
9491
(

0 commit comments

Comments
 (0)