Initial commit: OCA Edi packages (42 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:05 +02:00
commit df976c03db
2184 changed files with 571602 additions and 0 deletions

View file

@ -0,0 +1,132 @@
============
Base EDIFACT
============
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:05c6653f0f7b28dad1c23a6fbbd329329b0306b08f5577c19e376750c2c4f95d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github
:target: https://github.com/OCA/edi/tree/16.0/base_edifact
:alt: OCA/edi
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-base_edifact
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/edi&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module contains methods to generate and parse EDIFACT/D96A files
.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_
**Table of contents**
.. contents::
:local:
Installation
============
This module requires 'pydifact' python library.
Configuration
=============
Requires partner_identification_gln module to store GLN identifiers.
Partner identification code assigned by the European Article Numbering Association.
Use two identification categories:
- "GLN Identificatin Number". Partner identification like invoice or delivery address.
- "GCP Identification Number". Global Company Prefix.
If GCP codes are needed in UNB interchange header.
If you need group partners, consider oca/partner-contact/partner_company_group module.
Usage
=====
This module doesn't do anything useful by itself, but it is used by several other modules:
* *sale_order_import_edifact* that imports EDIFACT/D96A sale orders.
Changelog
=========
14.0.1.0.0 (2023-04-13)
~~~~~~~~~~~~~~~~~~~~~~~
Strong migration from 12.0.1.0.1 because it's not working for Amazon vendor orders.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/edi/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/edi/issues/new?body=module:%20base_edifact%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* ALBA Software
* PlanetaTIC
Contributors
~~~~~~~~~~~~
* Rafa Morant <rmorant@albasoft.com> (www.albasoft.com)
* Marc Poch <mpoch@planetatic.com>
* Duong (Tran Quoc) <duongtq@trobz.com>
* Tris Doan <tridm@trobz.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-rmorant| image:: https://github.com/rmorant.png?size=40px
:target: https://github.com/rmorant
:alt: rmorant
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-rmorant|
This module is part of the `OCA/edi <https://github.com/OCA/edi/tree/16.0/base_edifact>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,27 @@
# Copyright 2023 ALBA Software S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
{
"name": "Base EDIFACT",
"summary": "UN/EDIFACT/D96A utilities using pydifact parser",
"version": "16.0.1.5.1",
"development_status": "Alpha",
"category": "Tools",
"website": "https://github.com/OCA/edi",
"author": "ALBA Software, PlanetaTIC, Odoo Community Association (OCA)",
"maintainers": ["rmorant"],
"license": "AGPL-3",
"application": False,
"installable": True,
# "preloadable": True,
"external_dependencies": {
"python": ["pydifact"],
"bin": [],
},
"depends": [
# for configuration
"account",
"partner_identification",
"partner_identification_gln",
],
"data": [],
}

View file

@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_edifact
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_edifact
#: model:ir.model,name:base_edifact.model_base_edifact
msgid "Generate and parse Edifact documents"
msgstr ""

View file

@ -0,0 +1,19 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_edifact
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: base_edifact
#: model:ir.model,name:base_edifact.model_base_edifact
msgid "Generate and parse Edifact documents"
msgstr "Generiranje i parsiranje Edifact dokumenata"

View file

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_edifact
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-01 15:34+0000\n"
"Last-Translator: c2cdidier <didier.donze@camptocamp.com>\n"
"Language-Team: none\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: base_edifact
#: model:ir.model,name:base_edifact.model_base_edifact
msgid "Generate and parse Edifact documents"
msgstr "Générer et anaylser les documents Edifact"

View file

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_edifact
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-05-13 10:34+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: base_edifact
#: model:ir.model,name:base_edifact.model_base_edifact
msgid "Generate and parse Edifact documents"
msgstr "Genera ed elabora documenti Edifact"

View file

@ -0,0 +1 @@
from . import edifact

View file

@ -0,0 +1,294 @@
# Copyright 2023 ALBA Software S.L.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
import datetime
import logging
from pydifact.segmentcollection import Interchange, Message
from pydifact.segments import Segment
from odoo import api, models
logger = logging.getLogger(__name__)
# https://github.com/nerdocs/pydifact
class BasePydifact(models.AbstractModel):
_name = "base.edifact"
_description = "Generate and parse Edifact documents"
MAP_AGENCY_CODE_2_RES_PARTNER_NAMEREF = {"9": "gln"}
CURRENCY_SYMBOLS = {
"EUR": "",
"USD": "$",
}
PRODUCT_CODE_TYPES = {"EN": "EAN", "UP": "UPC", "SRV": "GTIN"}
@api.model
def pydifact_import(self, names):
classes = {
"Segment": Segment,
"Message": Message,
"Interchange": Interchange,
}
return [classes.get(name, None) for name in names]
@api.model
def pydifact_obj(self, docu):
obj = []
interchange = self._loads_edifact(docu)
header_seg = interchange.get_header_segment()
header_dict = dict()
header_dict[header_seg.tag] = header_seg.elements
obj.append(header_dict)
for message in interchange.get_messages():
segms = []
msg = {
"reference_number": message.reference_number,
"type": message.type,
"version": message.version,
"identifier": message.identifier,
"HEADER_TAG": message.HEADER_TAG,
"FOOTER_TAG": message.FOOTER_TAG,
"characters": str(message.characters),
"extra_header_elements": message.extra_header_elements,
"has_una_segment": message.has_una_segment,
}
logger.info(message)
for segment in message.segments:
logger.info(
"Segment tag: {}, content: {}".format(segment.tag, segment.elements)
)
# segms.append((segment.tag, segment.elements))
seg = dict()
seg[segment.tag] = segment.elements
segms.append(seg)
msg["segments"] = segms
obj.append(msg)
return obj
@api.model
def _loads_edifact(self, order_file):
# TODO: use chardet library for get encoding
try:
interchange = Interchange.from_str(order_file.decode())
except UnicodeDecodeError:
interchange = Interchange.from_str(order_file.decode("latin-1"))
return interchange
@api.model
def _get_msg_type(self, interchange):
seg = interchange.get_segment("UNH")
# MSG_TYPE, EDIFACT_MSG_TYPE_RELEASE
return (seg[1][0], "{}{}".format(seg[1][1], seg[1][2]))
@api.model
def map2odoo_date(self, dt):
# '102'
date_format = "%Y%m%d%H%M%S"
length_dt = len(dt[1])
if length_dt % 2 == 0 and length_dt in range(8, 13, 2):
date_format = date_format[0 : length_dt - 2]
dtt = datetime.datetime.strptime(dt[1], date_format)
return dtt.date()
@api.model
def map2odoo_partner(self, seg):
"""
BY. Party to which merchandise is sold.
NAD+BY+5550534000017::9'
NAD segment: ['BY', ['5550534001649', '', '9']]
SU. Party which manufactures or otherwise has possession of
goods,and consigns or makes them available in trade.
NAD+SU+<Supplier GLN>::9'
"""
partner_dict = {}
codes = ["BY", "SU"]
reference_code = seg[0]
if reference_code not in codes:
raise NotImplementedError(f"Code '{reference_code}' not implemented")
#
party_identification = seg[1]
party_id = party_identification[0]
agency_code = party_identification[2]
nameref = self.MAP_AGENCY_CODE_2_RES_PARTNER_NAMEREF.get(agency_code, "gln")
partner_dict[nameref] = party_id
return partner_dict
@api.model
def map2odoo_address(self, seg):
"""
DP. Party to which goods should be delivered, if not identical with
consignee.
NAD+DP+5550534000086::9+++++++DE'
NAD segment: ['DP', ['5550534022101', '', '9'], '', '', '', '', '', '', 'ES']
IV. Party to whom an invoice is issued.
NAD+IV+5450534005838::9++AMAZON EU SARL:NIEDERLASSUNG
DEUTSCHLAND+MARCEL-BREUER-STR. 12+MUENCHEN++80807+DE
:returns: {
'type':
'partner': {'gln':''}
'address': {...}
}
"""
if seg[0] not in ("DP", "IV"):
return False
order_type = "delivery" if seg[0] == "DP" else "invoice"
address = dict(type=order_type, partner={}, address={})
# PARTY IDENTIFICATION DETAILS
iden = seg[1]
party_id = iden[0]
agency_code = iden[2]
nameref = self.MAP_AGENCY_CODE_2_RES_PARTNER_NAMEREF.get(agency_code, "gln")
address["partner"][nameref] = party_id
d = address["address"]
# Fallback if address information is missing
try:
if isinstance(seg, Segment):
lenght_seg = len(seg.elements)
else:
lenght_seg = len(seg)
except ValueError:
lenght_seg = 0
# PARTY NAME
if lenght_seg > 2 and bool(seg[2]):
d["name"] = seg[2]
if lenght_seg > 3 and bool(seg[3]):
d["name"] = "{}{}".format(f"{d['name']}. " if d.get("name") else "", seg[3])
if lenght_seg > 4 and bool(seg[4]):
# Street address and/or PO Box number in a structured address: one to three lines.
d["street"] = seg[4]
if lenght_seg > 5 and bool(seg[5]):
d["city"] = seg[5]
if lenght_seg > 6 and bool(seg[6]):
# Country sub-entity identification
d["state_code"] = seg[6]
if lenght_seg > 7 and bool(seg[7]):
d["zip"] = seg[7]
if lenght_seg > 8 and bool(seg[8]):
# Country, coded ISO 3166
d["country_code"] = seg[8]
return address
@api.model
def map2odoo_currency(self, seg):
"""
['2', 'EUR', '9']
"""
# Identification of the name or symbol of the monetary unit involved in the transaction.
currency_coded = seg[1]
return {
"iso": currency_coded,
"symbol": self.CURRENCY_SYMBOLS.get(currency_coded, False),
}
@api.model
def map2odoo_product(self, seg, pia=None):
"""
:seg: LIN segment
['1', '', ['8885583503464', 'EN']]
EN. International Article Numbering Association (EAN)
UP. UPC (Universal product code)
SRV. GTIN
:pia: PIA segment
['5', ['1276', 'SA', '', '9']]
SA. Supplier's Article Number
"""
res = {}
# Set default code based on SA if given
if pia is not None and pia[1][0]:
res["code"] = pia[1][0]
code = seg[2][0] if len(list(seg)) > 2 else False
if code:
field = "code" if seg[2][1] == "SRV" else "barcode"
res[field] = code
return res
@api.model
def map2odoo_qty(self, seg):
"""
'QTY' EDI segment: [['21', '2']]
'21'. Ordered quantity
"""
return float(seg[0][1])
@api.model
def map2odoo_unit_price(self, seg=None):
"""
'PRI' EDI segment: [['AAA', '19.75']]
Price qualifier:
* 'AAA'. Calculation net
* 'AAB'. Calculation gross
"""
if seg:
pri = seg[0]
if pri[0] == "AAA":
return float(pri[1])
# TODO: Add price calculation formula
if pri[0] == "AAB":
return float(pri[1])
return 0.0
@api.model
def map2odoo_description(self, seg):
"""
'IMD' EDI segment: ['F', '79', ['', '', '', 'Description']]
F: Label
79: Other description
"""
if seg:
description = seg[2][3]
return description
return None
def _safe_segment_element(self, value):
if value is False:
return ""
return str(value)
@api.model
def create_segment(self, *elements):
cleaned_elements = []
for element in elements:
if isinstance(element, list):
cleaned_elements.append(
[self._safe_segment_element(value) for value in element]
)
else:
cleaned_elements.append(self._safe_segment_element(element))
return Segment(*cleaned_elements)
def create_interchange(self, sender, recipient, control_ref, syntax_identifier):
"""
Create an interchange (started by UNB segment, ended by UNZ segment)
:param list sender: Identification of the sender of the interchange.
example: ["40410", "14"]
- 40410: Identification of the sender of the interchange
- 14: EAN (European Article Numbering Association)
:param list recipient: Identification of the recipient of the interchange.
example: ["40411", "14"]
:param str control_ref: Unique reference assigned by the sender to an interchange.
example: "10"
:param list syntax_identifier: Identification of the agency controlling
the syntax and indication of syntax level, plus the syntax version number.
example: ["UNOC", "3"]
:return: Interchange object representing the created interchange.
:rtype: Interchange
"""
if not sender or not recipient or not control_ref or not syntax_identifier:
raise ValueError("All parameters must have values and not be False")
interchange = Interchange(
sender=(sender),
recipient=(recipient),
control_reference=str(control_ref),
syntax_identifier=(syntax_identifier),
)
return interchange

View file

@ -0,0 +1,12 @@
Requires partner_identification_gln module to store GLN identifiers.
Partner identification code assigned by the European Article Numbering Association.
Use two identification categories:
- "GLN Identificatin Number". Partner identification like invoice or delivery address.
- "GCP Identification Number". Global Company Prefix.
If GCP codes are needed in UNB interchange header.
If you need group partners, consider oca/partner-contact/partner_company_group module.

View file

@ -0,0 +1,4 @@
* Rafa Morant <rmorant@albasoft.com> (www.albasoft.com)
* Marc Poch <mpoch@planetatic.com>
* Duong (Tran Quoc) <duongtq@trobz.com>
* Tris Doan <tridm@trobz.com>

View file

@ -0,0 +1,2 @@
This module contains methods to generate and parse EDIFACT/D96A files

View file

@ -0,0 +1,4 @@
14.0.1.0.0 (2023-04-13)
~~~~~~~~~~~~~~~~~~~~~~~
Strong migration from 12.0.1.0.1 because it's not working for Amazon vendor orders.

View file

@ -0,0 +1,2 @@
This module requires 'pydifact' python library.

View file

@ -0,0 +1,4 @@
This module doesn't do anything useful by itself, but it is used by several other modules:
* *sale_order_import_edifact* that imports EDIFACT/D96A sale orders.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -0,0 +1,469 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Base EDIFACT</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="base-edifact">
<h1 class="title">Base EDIFACT</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:05c6653f0f7b28dad1c23a6fbbd329329b0306b08f5577c19e376750c2c4f95d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Alpha" src="https://img.shields.io/badge/maturity-Alpha-red.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/edi/tree/16.0/base_edifact"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/edi-16-0/edi-16-0-base_edifact"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/edi&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module contains methods to generate and parse EDIFACT/D96A files</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
<a class="reference external" href="https://odoo-community.org/page/development-status">More details on development status</a></p>
</div>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#installation" id="toc-entry-1">Installation</a></li>
<li><a class="reference internal" href="#configuration" id="toc-entry-2">Configuration</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-3">Usage</a></li>
<li><a class="reference internal" href="#changelog" id="toc-entry-4">Changelog</a><ul>
<li><a class="reference internal" href="#section-1" id="toc-entry-5">14.0.1.0.0 (2023-04-13)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-6">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-7">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-8">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-9">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-10">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="installation">
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
<p>This module requires pydifact python library.</p>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
<p>Requires partner_identification_gln module to store GLN identifiers.</p>
<p>Partner identification code assigned by the European Article Numbering Association.</p>
<p>Use two identification categories:</p>
<ul class="simple">
<li>“GLN Identificatin Number”. Partner identification like invoice or delivery address.</li>
<li>“GCP Identification Number”. Global Company Prefix.</li>
</ul>
<p>If GCP codes are needed in UNB interchange header.</p>
<p>If you need group partners, consider oca/partner-contact/partner_company_group module.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
<p>This module doesnt do anything useful by itself, but it is used by several other modules:</p>
<ul class="simple">
<li><em>sale_order_import_edifact</em> that imports EDIFACT/D96A sale orders.</li>
</ul>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#toc-entry-4">Changelog</a></h1>
<div class="section" id="section-1">
<h2><a class="toc-backref" href="#toc-entry-5">14.0.1.0.0 (2023-04-13)</a></h2>
<p>Strong migration from 12.0.1.0.1 because its not working for Amazon vendor orders.</p>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-6">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20base_edifact%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-7">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-8">Authors</a></h2>
<ul class="simple">
<li>ALBA Software</li>
<li>PlanetaTIC</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-9">Contributors</a></h2>
<ul class="simple">
<li>Rafa Morant &lt;<a class="reference external" href="mailto:rmorant&#64;albasoft.com">rmorant&#64;albasoft.com</a>&gt; (www.albasoft.com)</li>
<li>Marc Poch &lt;<a class="reference external" href="mailto:mpoch&#64;planetatic.com">mpoch&#64;planetatic.com</a>&gt;</li>
<li>Duong (Tran Quoc) &lt;<a class="reference external" href="mailto:duongtq&#64;trobz.com">duongtq&#64;trobz.com</a>&gt;</li>
<li>Tris Doan &lt;<a class="reference external" href="mailto:tridm&#64;trobz.com">tridm&#64;trobz.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-10">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/rmorant"><img alt="rmorant" src="https://github.com/rmorant.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/16.0/base_edifact">OCA/edi</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1 @@
from . import test_base_edifact

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -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'

View file

@ -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"])