Skip to content

Commit 37fd0dc

Browse files
committed
[IMP] base_wamas_ubl sub-transfer
1 parent 7727581 commit 37fd0dc

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

base_wamas_ubl/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Contributors
6464

6565
* Jacques-Etienne Baudoux <je@bcim.be>
6666
* Tuan Tran <anhtuan@trobz.com>
67+
* Telmo Santos <telmo.santos@camptocamp.com>
6768

6869
Other credits
6970
~~~~~~~~~~~~~

base_wamas_ubl/lib/wamas/wamas2ubl.py

+25-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import argparse
55
import logging
6+
from collections import OrderedDict
67
from pprint import pformat
78

89
from freezegun import freeze_time
@@ -45,29 +46,44 @@ def get_head(self, telegram_type, key_name, head=None):
4546
key,
4647
)
4748

48-
def get_line(self, telegram_type, transfer_key_name, package_key_name=False):
49+
def get_line(
50+
self,
51+
telegram_type,
52+
transfer_key1_name,
53+
transfer_key2_name=False,
54+
package_key_name=False,
55+
):
4956
"""Process a list of dict as lines of the transfers
5057
5158
Parameters:
5259
telegram_type: the key to get the list out of data
53-
transfer_key_name: the key in the dict that serves to identify the
60+
transfer_key1_name: the key in the dict that serves to identify the
5461
parent in transfers
62+
transfer_key2_name: the key in the dict that serves to identify a sub-transfer
5563
package_key_name: the key in the dict that serves to identify the
5664
related package
5765
"""
66+
transfers = {}
5867
if telegram_type not in self.data:
5968
raise ValueError("Missing telegram: %s" % telegram_type)
6069

6170
for line in self.data[telegram_type]:
62-
key = line[transfer_key_name]
71+
key = line[transfer_key1_name]
6372
if key not in self.transfers:
6473
_logger.debug(
6574
"Found %s (line) record for unknown transfer, ignoring: %s",
6675
telegram_type,
6776
key,
6877
)
6978
continue
70-
self.transfers[key].setdefault("lines", []).append(line)
79+
80+
# Create a key for the sub-transfer
81+
if transfer_key2_name:
82+
key = key + line[transfer_key2_name]
83+
if key not in transfers:
84+
# Copy parent transfer data
85+
transfers[key] = OrderedDict(self.transfers[line[transfer_key1_name]])
86+
transfers[key].setdefault("lines", []).append(line)
7187
if not package_key_name:
7288
continue
7389
package_id = line[package_key_name]
@@ -80,7 +96,7 @@ def get_line(self, telegram_type, transfer_key_name, package_key_name=False):
8096
)
8197
continue
8298
line["package"] = package
83-
self.transfers[key].setdefault("packages", []).append(package)
99+
transfers[key].setdefault("packages", []).append(package)
84100

85101

86102
def wamas2dict(msg):
@@ -121,7 +137,7 @@ def dict2ubl(msg_type, data, extra_data=False):
121137

122138
if msg_type == "ReceptionResponse":
123139
extractor.get_head("WEAKQ", "IvWevk_WevId_WevNr")
124-
extractor.get_line("WEAPQ", "IvWevp_WevId_WevNr")
140+
extractor.get_line("WEAPQ", "IvWevp_WevId_WevNr", "IvWevp_WEAP_WeaId_WeaNr")
125141
elif msg_type == "ReturnResponse":
126142
extractor.get_head("KRETKQ", "IvKretk_KretId_KretNr")
127143
extractor.get_line("KRETPQ", "IvKretp_KretId_KretNr")
@@ -131,7 +147,9 @@ def dict2ubl(msg_type, data, extra_data=False):
131147
extractor.get_line("AUSPQ", "IvAusp_UrAusId_AusNr")
132148
else:
133149
extractor.get_head("WATEKQ", "IvTek_TeId", extractor.packages)
134-
extractor.get_line("WATEPQ", "IvAusp_UrAusId_AusNr", "IvTep_TeId")
150+
extractor.get_line(
151+
"WATEPQ", "IvAusp_UrAusId_AusNr", package_key_name="IvTep_TeId"
152+
)
135153
else:
136154
raise Exception("Invalid message type: %s" % msg_type)
137155

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
* Jacques-Etienne Baudoux <je@bcim.be>
22
* Tuan Tran <anhtuan@trobz.com>
3+
* Telmo Santos <telmo.santos@camptocamp.com>

base_wamas_ubl/static/description/index.html

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
/*
1010
:Author: David Goodger (goodger@python.org)
11-
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1212
:Copyright: This stylesheet has been placed in the public domain.
1313
1414
Default cascading style sheet for the HTML output of Docutils.
15-
Despite the name, some widely supported CSS2 features are used.
1615
1716
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
@@ -275,7 +274,7 @@
275274
margin-left: 2em ;
276275
margin-right: 2em }
277276

278-
pre.code .ln { color: gray; } /* line numbers */
277+
pre.code .ln { color: grey; } /* line numbers */
279278
pre.code, code { background-color: #eeeeee }
280279
pre.code .comment, code .comment { color: #5C6576 }
281280
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +300,7 @@
301300
span.pre {
302301
white-space: pre }
303302

304-
span.problematic, pre.problematic {
303+
span.problematic {
305304
color: red }
306305

307306
span.section-subtitle {
@@ -412,6 +411,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
412411
<ul class="simple">
413412
<li>Jacques-Etienne Baudoux &lt;<a class="reference external" href="mailto:je&#64;bcim.be">je&#64;bcim.be</a>&gt;</li>
414413
<li>Tuan Tran &lt;<a class="reference external" href="mailto:anhtuan&#64;trobz.com">anhtuan&#64;trobz.com</a>&gt;</li>
414+
<li>Telmo Santos &lt;<a class="reference external" href="mailto:telmo.santos&#64;camptocamp.com">telmo.santos&#64;camptocamp.com</a>&gt;</li>
415415
</ul>
416416
</div>
417417
<div class="section" id="other-credits">
@@ -421,9 +421,7 @@ <h2><a class="toc-backref" href="#toc-entry-5">Other credits</a></h2>
421421
<div class="section" id="maintainers">
422422
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
423423
<p>This module is maintained by the OCA.</p>
424-
<a class="reference external image-reference" href="https://odoo-community.org">
425-
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
426-
</a>
424+
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
427425
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
428426
mission is to support the collaborative development of Odoo features and
429427
promote its widespread use.</p>

0 commit comments

Comments
 (0)