Skip to content

Commit

Permalink
[ADD] product_import_ubl
Browse files Browse the repository at this point in the history
  • Loading branch information
florentx committed Dec 2, 2022
1 parent 8e0b06e commit a65f0b3
Show file tree
Hide file tree
Showing 15 changed files with 794 additions and 0 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
account_invoice_import_facturx/tests/files/*
product_import_ubl/tests/files/*
3 changes: 3 additions & 0 deletions product_import_ubl/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
==================
Product UBL Import
==================
3 changes: 3 additions & 0 deletions product_import_ubl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import wizard
16 changes: 16 additions & 0 deletions product_import_ubl/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product UBL Import",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"summary": "Import UBL XML catalogue files",
"author": "Camptocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/edi",
"depends": [
"base_ubl",
"product_import",
],
}
1 change: 1 addition & 0 deletions product_import_ubl/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Florent Xicluna <[email protected]>
1 change: 1 addition & 0 deletions product_import_ubl/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module adds support for the import of product catalogues that comply with the `Universal Business Language (UBL) <http://ubl.xml.org/>`_ standard. The UBL standard became the `ISO/IEC 19845 <http://www.iso.org/iso/catalogue_detail.htm?csnumber=66370>`_ standard in December 2015 (cf the `official announce <http://www.prweb.com/releases/2016/01/prweb13186919.htm>_`).
3 changes: 3 additions & 0 deletions product_import_ubl/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from . import test_ubl_catalogue_import
118 changes: 118 additions & 0 deletions product_import_ubl/tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Copyright 2022 Camptocamp
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import base64
from functools import partial

from odoo.tools import DotDict, file_open


def _as_base64(filename):
path = f"product_import_ubl/tests/files/{filename}"
with file_open(path, "rb") as fobj:
data = fobj.read()
return base64.b64encode(data)


def get_test_data(env):
ref = env.ref
return {
"UBL-Catalogue_Example.xml": DotDict(
{
"_as_base64": partial(_as_base64, "UBL-Catalogue_Example.xml"),
"products": [
{
"active": True,
"name": "Copy paper",
"code": "MNTR011",
"barcode": False,
"product_code": "MNTR01349087911",
"description": "Photo copy paper 80g A4, package of 500 sheets.",
"uom": ref("uom.product_uom_lb"),
"currency": ref("base.EUR"),
"min_qty": 1.0,
"price": 10.0,
"company": False,
},
{
"active": True,
"name": "Copy paper",
"code": "MNTR012",
"barcode": False,
"product_code": "MNTR01349087912",
"description": (
"Photo copy paper 80g A4, carton of 10 units "
"with 500 sheets each"
),
"uom": ref("uom.product_uom_unit"),
"currency": ref("base.EUR"),
"min_qty": 0.0,
"price": 90.0,
"company": False,
},
],
}
),
"UBL-Catalogue_Example2.xml": DotDict(
{
"_as_base64": partial(_as_base64, "UBL-Catalogue_Example2.xml"),
"products": [
{
"active": True,
"name": "First product",
"code": "998000924",
"barcode": "1234567890924",
"product_code": "BOCAP-B",
"description": False,
"uom": ref("uom.product_uom_unit"),
"currency": ref("base.EUR"),
"min_qty": 1.0,
"price": 1.35,
"company": ref("base.main_company"),
},
{
"active": True,
"name": "Copy paper",
"code": "MNTR011X1",
"barcode": "1234567890114",
"product_code": "MNTR01349087911",
"description": "Photo copy paper 80g A4, package of 500 sheets.",
"uom": ref("uom.product_uom_unit"),
"currency": ref("base.EUR"),
"min_qty": 1.0,
"price": 12.55,
"company": ref("base.main_company"),
},
{
"active": True,
"name": "Copy paper",
"code": "MNTR012X2",
"barcode": "1234567890124",
"product_code": "MNTR01349087912",
"description": (
"Photo copy paper 80g A4, carton of 10 units "
"with 500 sheets each"
),
"uom": ref("uom.product_uom_unit"),
"currency": ref("base.EUR"),
"min_qty": 20.0,
"price": 91.5,
"company": ref("base.main_company"),
},
{
"active": False,
"name": "Copy paper, outdated",
"code": "MNTR010X9",
"barcode": False,
"product_code": False,
"description": False,
"uom": ref("uom.product_uom_unit"),
"currency": ref("base.USD"),
"min_qty": 0.0,
"price": 0.0,
"company": ref("base.main_company"),
},
],
}
),
}
Loading

0 comments on commit a65f0b3

Please sign in to comment.