6
6
7
7
from random import choice
8
8
9
+ from odoo import Command
9
10
from odoo .tests .common import Form , tagged
10
11
11
12
from odoo .addons .account .tests .common import AccountTestInvoicingCommon
@@ -91,9 +92,13 @@ def setUpClass(cls, chart_template_ref=None):
91
92
"name" : "Fixed Ecotax" ,
92
93
"type_tax_use" : "sale" ,
93
94
"company_id" : cls .env .user .company_id .id ,
95
+ "price_include" : True ,
94
96
"amount_type" : "code" ,
97
+ "include_base_amount" : True ,
98
+ "sequence" : 0 ,
95
99
"is_ecotax" : True ,
96
- "python_compute" : "result = product.fixed_ecotax or 0.0" ,
100
+ "python_compute" : "result = (quantity and"
101
+ " product.fixed_ecotax * quantity or 0.0)" ,
97
102
"tax_exigibility" : "on_invoice" ,
98
103
"invoice_repartition_line_ids" : [
99
104
(
@@ -141,8 +146,12 @@ def setUpClass(cls, chart_template_ref=None):
141
146
"type_tax_use" : "sale" ,
142
147
"company_id" : cls .env .user .company_id .id ,
143
148
"amount_type" : "code" ,
149
+ "include_base_amount" : True ,
150
+ "price_include" : True ,
151
+ "sequence" : 0 ,
144
152
"is_ecotax" : True ,
145
- "python_compute" : "result = product.weight_based_ecotax or 0.0" ,
153
+ "python_compute" : "result = (quantity and"
154
+ " product.weight_based_ecotax * quantity or 0.0)" ,
146
155
"tax_exigibility" : "on_invoice" ,
147
156
"invoice_repartition_line_ids" : [
148
157
(
@@ -193,6 +202,7 @@ def setUpClass(cls, chart_template_ref=None):
193
202
"default_fixed_ecotax" : 5.0 ,
194
203
"product_status" : "M" ,
195
204
"supplier_status" : "MAN" ,
205
+ "sale_ecotax_ids" : [(4 , cls .invoice_fixed_ecotax .id )],
196
206
}
197
207
)
198
208
cls .ecotax_fixed .sale_ecotax_ids = cls .invoice_fixed_ecotax
@@ -204,6 +214,7 @@ def setUpClass(cls, chart_template_ref=None):
204
214
"ecotax_coef" : 0.04 ,
205
215
"product_status" : "P" ,
206
216
"supplier_status" : "MAN" ,
217
+ "sale_ecotax_ids" : [(4 , cls .invoice_weight_based_ecotax .id )],
207
218
}
208
219
)
209
220
cls .ecotax_weight .sale_ecotax_ids = cls .invoice_weight_based_ecotax
@@ -214,13 +225,16 @@ def setUpClass(cls, chart_template_ref=None):
214
225
@classmethod
215
226
def _make_invoice (cls , products ):
216
227
"""Creates a new customer invoice with given products and returns it"""
217
- return cls .init_invoice (
228
+ invoice = cls .init_invoice (
218
229
"out_invoice" ,
219
230
partner = cls .invoice_partner ,
220
231
products = products ,
221
232
company = cls .env .user .company_id ,
222
233
taxes = cls .invoice_tax ,
223
234
)
235
+ invoice .invoice_line_ids ._compute_tax_ids ()
236
+ invoice .invoice_line_ids ._compute_ecotax ()
237
+ return invoice
224
238
225
239
@classmethod
226
240
def _make_product (cls , ecotax_classification ):
@@ -244,6 +258,7 @@ def _make_product(cls, ecotax_classification):
244
258
# and weight of 100
245
259
"list_price" : 100.00 ,
246
260
"weight" : 100.00 ,
261
+ "taxes_id" : [Command .set (cls .invoice_tax .ids )],
247
262
}
248
263
)
249
264
return tmpl .product_variant_ids [0 ]
@@ -462,38 +477,6 @@ def test_04_mixed_ecotax(self):
462
477
],
463
478
)
464
479
465
- def test_05_force_ecotax_on_invoice (self ):
466
- """Test force fixed ecotax
467
-
468
- Ecotax classification data for this test:
469
- - fixed type
470
- - default amount: 5.0
471
- - forced amount: 2
472
- Product data for this test:
473
- - list price: 100
474
- - fixed ecotax : 5
475
-
476
- Expected results (with 1 line and qty = 1):
477
- - invoice ecotax amount: 2.0
478
- - invoice total amount: 100.0
479
- - line ecotax unit amount: 2.0
480
- - line ecotax total amount: 2.0
481
- """
482
- product = self ._make_product (self .ecotax_fixed )
483
- invoice = self ._make_invoice (products = product )
484
- invoice .invoice_line_ids [0 ].ecotax_line_ids .force_amount_unit = 2
485
- self ._run_checks (
486
- invoice ,
487
- {"amount_ecotax" : 2.0 , "amount_total" : 100.0 },
488
- [{"ecotax_amount_unit" : 2.0 , "subtotal_ecotax" : 2.0 }],
489
- )
490
- new_qty = self ._set_invoice_lines_random_quantities (invoice )[0 ]
491
- self ._run_checks (
492
- invoice ,
493
- {"amount_ecotax" : 2.0 * new_qty , "amount_total" : 100.0 * new_qty },
494
- [{"ecotax_amount_unit" : 2.0 , "subtotal_ecotax" : 2.0 * new_qty }],
495
- )
496
-
497
480
def test_06_product_variants (self ):
498
481
"""
499
482
Data:
0 commit comments