-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] base_ubl: schemeID for GTIN is 0160 in peppol
- Loading branch information
Showing
3 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_ubl_generate | ||
from . import test_ubl_parse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |