mirror of
https://github.com/bringout/oca-edi.git
synced 2026-04-18 15:52:06 +02:00
Initial commit: OCA Edi packages (42 packages)
This commit is contained in:
commit
df976c03db
2184 changed files with 571602 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
from . import test_base_edifact
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
UNB+UNOA:2+5450534000000:14+8450534000000:14+221117:0134+4234++++1+EANCOM'
|
||||
UNH+1+ORDERS:D:96A:UN:EAN008'
|
||||
BGM+220+1AA1TEST+9'
|
||||
DTM+137:20230606:102'
|
||||
DTM+63:20230606:102'
|
||||
DTM+64:20230606:102'
|
||||
RFF+CR:ABCD5'
|
||||
NAD+BY+5450534000017::9'
|
||||
NAD+SU+8450534000000::9'
|
||||
NAD+DP+5450534008617::9+++++++GB'
|
||||
NAD+IV+5450534008143::9++AMAZON EU SARL+38 Avenue J.F. Kennedy+Luxembourg++1855+LU'
|
||||
RFF+VA:LU20260743'
|
||||
CUX+2:EUR:9'
|
||||
LIN+1++9783898307529:EN'
|
||||
QTY+21:5'
|
||||
PRI+AAA:27.5'
|
||||
LIN+2++9783898307538:EN'
|
||||
QTY+21:1'
|
||||
PRI+AAA:10.87'
|
||||
LIN+3++9783898307645:EN'
|
||||
QTY+21:3'
|
||||
PRI+AAA:3.85'
|
||||
UNS+S'
|
||||
CNT+2:3'
|
||||
UNT+24+1'
|
||||
UNZ+1+4234'
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
UNB+UNOA:2+5450534000000:14+<Receiver GLN>:14+221117:0134+4234++++1+EANCOM'
|
||||
UNH+1+ORDERS:D:96A:UN:EAN008'
|
||||
BGM+220+1AA1TEST+9'
|
||||
DTM+137:20221117:102'
|
||||
DTM+63:20221127:102'
|
||||
DTM+64:20221124:102'
|
||||
RFF+CR:ABCD5'
|
||||
NAD+BY+5450534000017::9'
|
||||
NAD+SU+<Supplier GLN>::9'
|
||||
NAD+DP+5450534000086::9+++++++DE'
|
||||
NAD+IV+5450534005838::9++AMAZON EU SARL:NIEDERLASSUNG DEUTSCHLAND+MARCEL-BREUER-STR. 12+MUENCHEN++80807+DE'
|
||||
RFF+VA:DE814584193'
|
||||
CUX+2:EUR:9'
|
||||
LIN+1'
|
||||
PIA+5+567123:SA'
|
||||
QTY+21:5'
|
||||
PRI+AAA:27.5'
|
||||
LIN+2'
|
||||
PIA+5+1234567:SA'
|
||||
QTY+21:1'
|
||||
PRI+AAA:10.87'
|
||||
LIN+3'
|
||||
PIA+5+765432:SA'
|
||||
QTY+21:3'
|
||||
PRI+AAA:3.85'
|
||||
UNS+S'
|
||||
CNT+2:3'
|
||||
UNT+27+1'
|
||||
UNZ+1+4234'
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
UNA:+.? '
|
||||
UNB+UNOC:3+ENI-CH:14+2256:14+230320:1910+2'
|
||||
UNH+000011956901+ORDERS:D:96A:UN:EAN008'
|
||||
BGM+220+COM-004017+9'
|
||||
DTM+137:20230320:102'
|
||||
DTM+2:20230321:102'
|
||||
NAD+BY+5450534008617::91'
|
||||
NAD+BY+5450534008143::92++PartyName1+Address1+City1++1964'
|
||||
NAD+SU+2256::9'
|
||||
NAD+DP+5450534008617::91++PartyName1+Address1+City1++1964'
|
||||
RFF+API:5450534008617'
|
||||
LIN+1++9783898307529:EN'
|
||||
PIA+1+7076:SA::91+30007:BP::92'
|
||||
QTY+21:8:6'
|
||||
LIN+2++9783898307538:EN'
|
||||
PIA+1+7065:SA::91+38812:BP::92'
|
||||
QTY+21:4:6'
|
||||
LIN+3++9783898307645:EN'
|
||||
PIA+1+7056:SA::91+30008:BP::92'
|
||||
QTY+21:1:24'
|
||||
UNS+S'
|
||||
CNT+2:3'
|
||||
UNT+267+000011956901'
|
||||
UNZ+1+2'
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
UNB+UNOC:3+3027800012009:14+7640142640004:14+230320:1438+003274'
|
||||
UNH+3269+ORDERS:D:96A:UN:EAN008'
|
||||
BGM+220::9:ORDERS+467819+9'
|
||||
DTM+137:202303201433:203'
|
||||
DTM+2:202303220000:203'
|
||||
NAD+SU+7640142640004::9++Suppliér1+Address1+City1++1762+CH'
|
||||
RFF+IT:5020'
|
||||
NAD+BY+5450534008617::ZZ++'
|
||||
RFF+IT:5132'
|
||||
CTA+OC+:RADON'
|
||||
NAD+SF+++'
|
||||
NAD+IV+5450534008617::ZZ++Suppliér1+Address1+City1++3110+CH'
|
||||
RFF+IT:5132'
|
||||
NAD+DP+5450534008617::ZZ++Suppliér1+Address1+City1++3110+CH'
|
||||
RFF+IT:5132'
|
||||
RFF+GN:RCS'
|
||||
CUX+2:EUR:9'
|
||||
ALC+C++6++FC::9:FRAIS DE PORT'
|
||||
MOA+23:0'
|
||||
LIN+1++:EN'
|
||||
PIA+5+1276:SA::9'
|
||||
PIA+5+31136:IN::9'
|
||||
PIA+5+00:VL'
|
||||
IMD+F+ANM+:::Product1'
|
||||
IMD+F+79+:::Product1 description'
|
||||
QTY+21:12:BOU'
|
||||
QTY+59:6:PCE'
|
||||
PRI+AAB:5.22::NTP'
|
||||
LIN+2++:EN'
|
||||
PIA+5+46630:SA::9'
|
||||
PIA+5+27952:IN::9'
|
||||
PIA+5+00:VL'
|
||||
IMD+F+ANM+:::Product2'
|
||||
IMD+F+79+:::Product2 Description'
|
||||
QTY+21:24:BOU'
|
||||
QTY+59:24:PCE'
|
||||
PRI+AAB:27.641::NTP'
|
||||
LIN+3++:EN'
|
||||
PIA+5+98891 75:SA::9'
|
||||
PIA+5+22389:IN::9'
|
||||
PIA+5+00:VL'
|
||||
IMD+F+ANM+:::Product3'
|
||||
IMD+F+79+:::Product3 Description'
|
||||
QTY+21:12:BOU'
|
||||
QTY+59:6:PCE'
|
||||
PRI+AAB:51.03::NTP'
|
||||
LIN+4++:EN'
|
||||
PIA+5+37230:SA::9'
|
||||
PIA+5+16344:IN::9'
|
||||
PIA+5+00:VL'
|
||||
IMD+F+ANM+:::Product4'
|
||||
IMD+F+79+:::Product4 Description'
|
||||
QTY+21:24:BOU'
|
||||
QTY+59:24:PCE'
|
||||
PRI+AAB:29.542::NTP'
|
||||
LIN+5++:EN'
|
||||
PIA+5+1076:SA::9'
|
||||
PIA+5+16270:IN::9'
|
||||
PIA+5+00:VL'
|
||||
IMD+F+ANM+:::Product5'
|
||||
IMD+F+79+:::Product5 Description'
|
||||
QTY+21:90:BOU'
|
||||
QTY+59:6:PCE'
|
||||
PRI+AAB:5.22::NTP'
|
||||
UNS+S'
|
||||
MOA+125:247.98'
|
||||
CNT+2:5'
|
||||
UNT+67+3269'
|
||||
UNZ+1+003274'
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
# Copyright 2023 ALBA Software S.L.
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
|
||||
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tools import file_open
|
||||
|
||||
|
||||
def _get_file_content(filename):
|
||||
path = "base_edifact/tests/files/" + filename
|
||||
with file_open(path, "rb") as fd:
|
||||
return fd.read()
|
||||
|
||||
|
||||
class TestBaseEdifact(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.base_edifact_model = cls.env["base.edifact"]
|
||||
cls.product = cls.env.ref("product.product_product_1")
|
||||
cls.product.barcode = "9783898"
|
||||
cls.product.default_code = "12767"
|
||||
|
||||
def test_pydifact_obj(self):
|
||||
edifact_docu = _get_file_content("Retail_EDIFACT_ORDERS_sample1.txt")
|
||||
obj = self.base_edifact_model.pydifact_obj(edifact_docu)
|
||||
# [1]: to get the list messages, [0]: to get the first list value of the segments
|
||||
self.assertEqual(obj[1]["segments"][0]["BGM"][1], "1AA1TEST")
|
||||
|
||||
def test_pydifact_obj_latin1(self):
|
||||
edifact_docu = _get_file_content("test_orders_-_no_ean_in_LIN_segments.txt")
|
||||
obj = self.base_edifact_model.pydifact_obj(edifact_docu)
|
||||
# [1]: to get the list messages, [3]: to get the third list value of the segments
|
||||
self.assertEqual(obj[1]["segments"][3]["NAD"][3], "Suppliér1")
|
||||
|
||||
def test_map2odoo_address(self):
|
||||
"""Address segment
|
||||
DP. Party to which goods should be delivered, if not identical with
|
||||
consignee.
|
||||
NAD+DP+5550534000086::9+++++++DE'
|
||||
NAD segment: ['DP', ['5550534022101', '', '9'], '', '', '', '', '', '', 'ES']
|
||||
"""
|
||||
seg = ["DP", ["5550534000086", "", "9"], "", "", "", "", "", "", "ES"]
|
||||
address = self.base_edifact_model.map2odoo_address(seg)
|
||||
self.assertEqual(address["type"], "delivery")
|
||||
self.assertEqual(address["partner"], {"gln": "5550534000086"})
|
||||
self.assertEqual(address["address"]["country_code"], "ES")
|
||||
|
||||
def test_map2odoo_currency(self):
|
||||
seg = ("2", "EUR", "9")
|
||||
currency = self.base_edifact_model.map2odoo_currency(seg)
|
||||
self.assertEqual(currency["iso"], "EUR")
|
||||
self.assertEqual(currency["symbol"], "€")
|
||||
|
||||
def test_map2odoo_product(self):
|
||||
seg = ("1", "", ["9783898", "EN"])
|
||||
product = self.base_edifact_model.map2odoo_product(seg)
|
||||
self.assertEqual(product["barcode"], "9783898")
|
||||
|
||||
def test_map2odoo_product_srv(self):
|
||||
seg = ("1", "", ["12767", "SRV"])
|
||||
product = self.base_edifact_model.map2odoo_product(seg)
|
||||
self.assertEqual(product["code"], "12767")
|
||||
|
||||
def test_map2odoo_product_no_lin_has_pia(self):
|
||||
seg = ("1", "", ["", "EN"])
|
||||
pia = ["5", ["12767", "SA", "", "9"]]
|
||||
product = self.base_edifact_model.map2odoo_product(seg, pia)
|
||||
self.assertEqual(product["code"], "12767")
|
||||
|
||||
def test_map2odoo_product_no_lin_and_no_pia(self):
|
||||
seg = ("1", "", ["", "EN"])
|
||||
product = self.base_edifact_model.map2odoo_product(seg)
|
||||
self.assertEqual(product, {})
|
||||
|
||||
def test_map2odoo_qty(self):
|
||||
seg = (["21", "2"],)
|
||||
qty = self.base_edifact_model.map2odoo_qty(seg)
|
||||
self.assertEqual(qty, 2.0)
|
||||
|
||||
def test_map2odoo_unit_price(self):
|
||||
# Test with Price qualifier is AAA
|
||||
seg = (["AAA", "19.75"],)
|
||||
unit_price = self.base_edifact_model.map2odoo_unit_price(seg)
|
||||
self.assertEqual(unit_price, 19.75)
|
||||
# Test with no unit price
|
||||
unit_price = self.base_edifact_model.map2odoo_unit_price()
|
||||
self.assertEqual(unit_price, 0.0)
|
||||
|
||||
def test_map2odoo_date(self):
|
||||
# Test with date format YYYY-MM-DD HH:MM
|
||||
date_str = ["137", "202303201433", "203"]
|
||||
date = self.base_edifact_model.map2odoo_date(date_str)
|
||||
self.assertEqual(str(date), "2023-03-20")
|
||||
|
||||
def test_map2odoo_description(self):
|
||||
seg = ["F", "79", ["", "", "", "Description"]]
|
||||
description = self.base_edifact_model.map2odoo_description(seg)
|
||||
self.assertEqual(description, "Description")
|
||||
|
||||
def test_create_segment(self):
|
||||
segment = self.base_edifact_model.create_segment("DTM", ["171", False, "102"])
|
||||
self.assertEqual(str(segment), "'DTM' EDI segment: [['171', '', '102']]")
|
||||
|
||||
def test_create_interchange(self):
|
||||
sender_edifact = ["40410", "14"]
|
||||
recipient_edifact = ["40411", "14"]
|
||||
control_ref = 10
|
||||
syntax_identifier = ["UNOC", "3"]
|
||||
interchange = self.base_edifact_model.create_interchange(
|
||||
sender_edifact, recipient_edifact, control_ref, syntax_identifier
|
||||
)
|
||||
self.assertEqual(interchange.sender, ["40410", "14"])
|
||||
self.assertEqual(interchange.recipient, ["40411", "14"])
|
||||
self.assertEqual(interchange.control_reference, "10")
|
||||
self.assertEqual(interchange.syntax_identifier, ["UNOC", "3"])
|
||||
Loading…
Add table
Add a link
Reference in a new issue