Skip to content

Commit

Permalink
[IMP] delivery_tnt_oca: Multiple package support
Browse files Browse the repository at this point in the history
  • Loading branch information
hildickethan authored and miguel-S73 committed Jun 2, 2023
1 parent 2205955 commit d252e52
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 18 deletions.
1 change: 1 addition & 0 deletions delivery_tnt_oca/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ class StockPicking(models.Model):
tnt_consignment_xray = fields.Char(sparse="tnt_consignment_data")
tnt_piece_data = fields.Serialized()
tnt_piece_barcode = fields.Char(sparse="tnt_piece_data")
tnt_piece_weight = fields.Char(sparse="tnt_piece_data")
17 changes: 13 additions & 4 deletions delivery_tnt_oca/models/tnt_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,23 +455,32 @@ def _get_label_info(self):
res = res["consignment"]
p_data = res["pieceLabelData"]
c_data = res["consignmentLabelData"]
twoDBarcode_text_split = p_data["twoDBarcode"]["#text"].split("|")
if not isinstance(p_data, list):
p_data = [p_data]
p_data_parsed = {"dates": [], "barcodes": [], "options": [], "weights": []}
for piece in p_data:
twoDBarcode_text_split = piece["twoDBarcode"]["#text"].split("|")
p_data_parsed["dates"].append(twoDBarcode_text_split[-2])
p_data_parsed["barcodes"].append(piece["barcode"]["#text"])
p_data_parsed["options"].append(twoDBarcode_text_split[19])
p_data_parsed["weights"].append(piece["weightDisplay"]["@code"])
c_data_fcd = c_data["freeCirculationDisplay"]
c_data_dd = c_data["destinationDepot"]
vals = {
"tnt_consignment_mumber": c_data["consignmentNumber"],
"tnt_consignment_date": twoDBarcode_text_split[-2],
"tnt_consignment_date": "|".join(p_data_parsed["dates"]),
"tnt_consignment_free_circulation": c_data_fcd["#text"],
"tnt_consignment_sort_split": c_data["sortSplitText"],
"tnt_consignment_destination_depot": c_data_dd["depotCode"],
"tnt_consignment_destination_depot_day": c_data_dd["dueDayOfMonth"],
"tnt_consignment_cluster_code": c_data["clusterCode"],
"tnt_consignment_origin_depot": c_data["originDepot"]["depotCode"],
"tnt_consignment_product": c_data["product"]["#text"],
"tnt_consignment_option": twoDBarcode_text_split[19],
"tnt_consignment_option": "|".join(p_data_parsed["options"]),
"tnt_consignment_market": c_data["marketDisplay"]["#text"],
"tnt_consignment_transport": c_data["transportDisplay"]["#text"],
"tnt_piece_barcode": p_data["barcode"]["#text"],
"tnt_piece_barcode": "|".join(p_data_parsed["barcodes"]),
"tnt_piece_weight": "|".join(p_data_parsed["weights"]),
}
if "transitDepots" in c_data and c_data["transitDepots"]:
transitDepot = c_data["transitDepots"]["transitDepot"]
Expand Down
55 changes: 41 additions & 14 deletions delivery_tnt_oca/report/picking_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
<template id="label_delivery_tnt_oca_template">
<t t-foreach="docs" t-as="picking">
<t t-foreach="range(picking.number_of_packages)" t-as="package_number">
<t
t-set="date"
t-value="picking.tnt_consignment_date.split('|')[package_number]"
/>
<t
t-set="option"
t-value="picking.tnt_consignment_option.split('|')[package_number]"
/>
<t
t-set="barcode"
t-value="picking.tnt_piece_barcode.split('|')[package_number]"
/>
<t
t-set="weight"
t-value="picking.tnt_piece_weight.split('|')[package_number]"
/>
<t t-translation="off">
^XA
^CI28
Expand Down Expand Up @@ -59,19 +75,17 @@
^FT232,120^A0N,39,54^FD^FS
^FB400,3,0,L,0^FT232,177^A0N,17,18^FD<t t-esc="picking.tnt_consignment_xray" />^FS
^FT424,240^A0N,34,39^FR^FD<t t-esc="picking.tnt_consignment_product" />^FS
^FT424,317^A0N,34,39^FR^FD<t t-esc="picking.tnt_consignment_option" />^FS
^FT424,317^A0N,34,39^FR^FD<t t-esc="option" />^FS
^FT440,310^A0N,34,39^FD^FS
^FT480,388^A0N,56,64^FD<t t-esc="picking.tnt_consignment_origin_depot" />^FS
^FT640,375^A0N,23,28^FD<t t-esc="picking.tnt_consignment_date" />^FS
^FT640,375^A0N,23,28^FD<t t-esc="date" />^FS
^FT620,138^A0N,102,150^FR^FD<t t-esc="picking.tnt_consignment_free_circulation" />^FS
^FT710,138^A0N,102,150^FD<t t-esc="picking.tnt_consignment_sort_split" />^FS
^FT32,248^A0N,45,57^FD<t t-esc="picking.tnt_consignment_mumber" />^FS
^FT32,317^A0N,28,32^FD<t t-esc="package_number+1" /> of <t
t-esc="picking.number_of_packages"
/>^FS
^FT240,317^A0N,28,32^FR^FD<t t-esc="picking.weight" /><t
t-esc="picking.weight_uom_name"
/>^FS
^FT240,317^A0N,28,32^FR^FD<t t-esc="weight" /><t t-esc="picking.weight_uom_name" />^FS
^FT24,373^A0N,25,23^FD<t t-esc="picking.name" />^FS
^FT184,417^A0N,25,27^FD<t t-esc="picking.carrier_id.tnt_oca_ws_account" />^FS
^FT141,902^A0N,73,58^FR^FD<t t-esc="picking.tnt_consignment_cluster_code" />^FS
Expand All @@ -97,8 +111,8 @@
^FT496,915^A0N,80,82^FD<t t-esc="picking.tnt_consignment_destination_depot" /> <t
t-esc="picking.tnt_consignment_destination_depot_day"
/>^FS
^FO82,945^BY3^BCN,220,N,N^FD>;<t t-esc="picking.tnt_piece_barcode" />^FS
^FT160,1187^A0N,23,32^FD<t t-esc="picking.tnt_piece_barcode" />^FS
^FO82,945^BY3^BCN,220,N,N^FD>;<t t-esc="barcode" />^FS
^FT160,1187^A0N,23,32^FD<t t-esc="barcode" />^FS
^FO17,66 ^XGR:SSGFX000.GRF,1,1^FS
^PQ1,0,1,Y
^XZ
Expand All @@ -112,6 +126,22 @@
<template id="tnt_label_pdf_template">
<t t-call="web.basic_layout">
<t t-foreach="range(doc.number_of_packages)" t-as="package_number">
<t
t-set="date"
t-value="doc.tnt_consignment_date.split('|')[package_number]"
/>
<t
t-set="consign_option"
t-value="doc.tnt_consignment_option.split('|')[package_number]"
/>
<t
t-set="barcode"
t-value="doc.tnt_piece_barcode.split('|')[package_number]"
/>
<t
t-set="weight"
t-value="doc.tnt_piece_weight.split('|')[package_number]"
/>
<style>
.font_8_n{
font-size:8pt;
Expand Down Expand Up @@ -245,7 +275,7 @@
<div class="col-6" style="padding-left:5px;">
<span class="font_8_n">Weight</span>
<br />
<span class="font_14_b" t-esc="doc.weight" /><span
<span class="font_14_b" t-esc="weight" /><span
class="font_14_b"
t-esc="doc.weight_uom_name"
/>
Expand All @@ -261,7 +291,7 @@
<span
class="font_12_b"
style="text-align:center"
t-esc="doc.tnt_consignment_option"
t-esc="consign_option"
/>
</div>
</div>
Expand Down Expand Up @@ -367,10 +397,7 @@
<div class="col-6">
<span class="font_8_n">Pickup Date</span>
<br />
<span
class="font_8_n"
t-esc="doc.tnt_consignment_date"
/>
<span class="font_8_n" t-esc="date" />
</div>
</div>
</div>
Expand Down Expand Up @@ -422,7 +449,7 @@
>
<div class="text-center" style="padding:0;">
<img
t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s&amp;humanreadable=1' % ('Code128', doc.tnt_piece_barcode,800,180)"
t-att-src="'/report/barcode/?barcode_type=%s&amp;value=%s&amp;width=%s&amp;height=%s&amp;humanreadable=1' % ('Code128', barcode,800,180)"
style="width:100%;height:100%"
/>
</div>
Expand Down

0 comments on commit d252e52

Please sign in to comment.