mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[14.0][IMP] intrastat_product: Add test for declaration line values
This commit is contained in:
@@ -11,6 +11,36 @@ class IntrastatSaleCommon(IntrastatProductCommon):
|
|||||||
- Customer in Netherlands
|
- Customer in Netherlands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def _check_line_values(self, final=False, declaration=None, sale=None):
|
||||||
|
"""
|
||||||
|
This method allows to test computation lines and declaration
|
||||||
|
lines values from original sale order line
|
||||||
|
"""
|
||||||
|
if declaration is None:
|
||||||
|
declaration = self.declaration
|
||||||
|
if sale is None:
|
||||||
|
sale = self.sale
|
||||||
|
for line in sale.order_line:
|
||||||
|
expected_vals = {
|
||||||
|
"declaration_type": "dispatches",
|
||||||
|
"suppl_unit_qty": line.qty_delivered,
|
||||||
|
"hs_code_id": line.product_id.hs_code_id,
|
||||||
|
"product_origin_country_id": line.product_id.origin_country_id,
|
||||||
|
}
|
||||||
|
comp_line = declaration.computation_line_ids.filtered(
|
||||||
|
lambda cline: cline.product_id == line.product_id
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
all(comp_line[key] == val for key, val in expected_vals.items())
|
||||||
|
)
|
||||||
|
if final:
|
||||||
|
decl_line = declaration.declaration_line_ids.filtered(
|
||||||
|
lambda dline: comp_line in dline.computation_line_ids
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
all(decl_line[key] == val for key, val in expected_vals.items())
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _init_customer(cls, vals=None):
|
def _init_customer(cls, vals=None):
|
||||||
values = {
|
values = {
|
||||||
|
|||||||
@@ -79,13 +79,9 @@ class TestIntrastatProductSale(IntrastatSaleCommon):
|
|||||||
self._create_declaration(vals)
|
self._create_declaration(vals)
|
||||||
self.declaration.action_gather()
|
self.declaration.action_gather()
|
||||||
|
|
||||||
expected_vals = {
|
self._check_line_values()
|
||||||
"declaration_type": "dispatches",
|
self.declaration.generate_declaration()
|
||||||
"suppl_unit_qty": 3.0,
|
self._check_line_values(final=True)
|
||||||
"hs_code_id": self.hs_code_computer,
|
|
||||||
}
|
|
||||||
line = self.declaration.computation_line_ids
|
|
||||||
self.assertDictContainsSubset(expected_vals, line)
|
|
||||||
|
|
||||||
|
|
||||||
class TestIntrastatProductSaleCase(TestIntrastatProductSale, SavepointCase):
|
class TestIntrastatProductSaleCase(TestIntrastatProductSale, SavepointCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user