Skip to content

Commit f796b06

Browse files
thienvh332OCA-git-bot
authored andcommitted
[IMP] sale_order_import_edifact: add testcase for no ean in LIN segment
1 parent 0facfa5 commit f796b06

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

sale_order_import_edifact/tests/common.py

+25
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,28 @@ def get_test_data(env):
4040
}
4141
)
4242
}
43+
44+
45+
def get_test_data_no_ean_in_lin(env):
46+
ref = env.ref
47+
return {
48+
"test_orders_-_no_ean_in_LIN_segments.txt": DotDict(
49+
{
50+
"_get_content": partial(
51+
_get_file_content, "test_orders_-_no_ean_in_LIN_segments.txt"
52+
),
53+
"client_order_ref": "467819",
54+
"date_order": "2023-03-20",
55+
"partner": ref("sale_order_import_edifact.partner_edi_shipto_dm"),
56+
"shipping_partner": ref(
57+
"sale_order_import_edifact.partner_edi_shipto_dm"
58+
),
59+
"products": ref("sale_order_import_edifact.product_product_edifact4_dm")
60+
+ ref("sale_order_import_edifact.product_product_edifact5_dm")
61+
+ ref("sale_order_import_edifact.product_product_edifact6_dm")
62+
+ ref("sale_order_import_edifact.product_product_edifact7_dm")
63+
+ ref("sale_order_import_edifact.product_product_edifact8_dm"),
64+
"qty": [12.0, 24.0, 12.0, 24.0, 90.0],
65+
}
66+
)
67+
}

sale_order_import_edifact/tests/test_edifact_order_import.py

+35-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from odoo.tests.common import TransactionCase
77
from odoo.tools import mute_logger
88

9-
from .common import get_test_data
9+
from .common import get_test_data, get_test_data_no_ean_in_lin
1010

1111

1212
class TestEdifactOrderImport(TransactionCase):
@@ -44,3 +44,37 @@ def test_edifact_order_import(self):
4444
self.assertEqual(
4545
sorted(so.order_line.mapped("product_id").ids), expected_ids
4646
)
47+
48+
@mute_logger("odoo.addons.sale_order_import.wizard.sale_order_import")
49+
def test_edifact_order_import_no_ean_in_lin(self):
50+
tests = get_test_data_no_ean_in_lin(self.env)
51+
for filename, expected in tests.items():
52+
edifact_file = expected._get_content()
53+
wiz = self.env["sale.order.import"].create(
54+
{
55+
"import_type": "edifact",
56+
"order_file": base64.b64encode(edifact_file),
57+
"order_filename": filename,
58+
}
59+
)
60+
action = wiz.import_order_button()
61+
so = self.env["sale.order"].browse(action["res_id"])
62+
self.assertEqual(so.partner_id, expected["partner"])
63+
64+
if expected.get("client_order_ref"):
65+
self.assertEqual(so.client_order_ref, expected["client_order_ref"])
66+
67+
if expected.get("shipping_partner"):
68+
self.assertEqual(so.partner_shipping_id, expected["shipping_partner"])
69+
70+
if expected.get("products"):
71+
expected_ids = sorted(expected["products"].ids)
72+
self.assertEqual(
73+
sorted(so.order_line.mapped("product_id").ids), expected_ids
74+
)
75+
self.assertEqual(
76+
so.order_line.mapped("product_uom_qty"), expected["qty"]
77+
)
78+
self.assertEqual(
79+
so.order_line.mapped("name")[0], "Product1 description"
80+
)

0 commit comments

Comments
 (0)