mirror of
https://github.com/bringout/oca-edi.git
synced 2026-04-19 13:51:59 +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,56 @@
|
|||
# Copyright 2024 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from lxml import etree
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestBaseUblParse(TransactionCase):
|
||||
def test_parse_product_schemeid_gtin(self):
|
||||
xml_string = b"""<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Root
|
||||
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
|
||||
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||
>
|
||||
<cac:Item>
|
||||
<cbc:Description>Acme beeswax</cbc:Description>
|
||||
<cbc:Name>beeswax</cbc:Name>
|
||||
<cac:StandardItemIdentification>
|
||||
<cbc:ID schemeID="GTIN">6578489</cbc:ID>
|
||||
</cac:StandardItemIdentification>
|
||||
<cac:SellersItemIdentification>
|
||||
<cbc:ID>17589683</cbc:ID>
|
||||
</cac:SellersItemIdentification>
|
||||
</cac:Item>
|
||||
</Root>
|
||||
"""
|
||||
xml_root = etree.fromstring(xml_string)
|
||||
ns = xml_root.nsmap
|
||||
product = self.env["base.ubl"].ubl_parse_product(xml_root, ns)
|
||||
self.assertEqual(product.get("barcode"), "6578489")
|
||||
self.assertEqual(product.get("code"), "17589683")
|
||||
|
||||
def test_parse_product_schemeid_0160(self):
|
||||
xml_string = b"""<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<Root
|
||||
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
|
||||
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
|
||||
>
|
||||
<cac:Item>
|
||||
<cbc:Description>Acme beeswax</cbc:Description>
|
||||
<cbc:Name>beeswax</cbc:Name>
|
||||
<cac:StandardItemIdentification>
|
||||
<cbc:ID schemeID="0160">6578489</cbc:ID>
|
||||
</cac:StandardItemIdentification>
|
||||
<cac:SellersItemIdentification>
|
||||
<cbc:ID>17589683</cbc:ID>
|
||||
</cac:SellersItemIdentification>
|
||||
</cac:Item>
|
||||
</Root>
|
||||
"""
|
||||
xml_root = etree.fromstring(xml_string)
|
||||
ns = xml_root.nsmap
|
||||
product = self.env["base.ubl"].ubl_parse_product(xml_root, ns)
|
||||
self.assertEqual(product.get("barcode"), "6578489")
|
||||
self.assertEqual(product.get("code"), "17589683")
|
||||
Loading…
Add table
Add a link
Reference in a new issue