@@ -37,6 +37,7 @@ def parse_ubl_despatch_advice(self, xml_root):
37
37
"cac:EstimatedDeliveryPeriod/cbc:EndDate" ,
38
38
namespaces = ns ,
39
39
)
40
+ order_id_xpath = xml_root .xpath ("/main:DespatchAdvice/cbc:ID" , namespaces = ns )
40
41
order_reference_xpath = xml_root .xpath (
41
42
"/main:DespatchAdvice/cac:OrderReference/cbc:ID" , namespaces = ns
42
43
)
@@ -66,12 +67,15 @@ def parse_ubl_despatch_advice(self, xml_root):
66
67
for line in lines_xpath :
67
68
res_lines .append (self .parse_ubl_despatch_advice_line (line , ns ))
68
69
res = {
70
+ "id" : order_id_xpath [0 ].text if order_id_xpath else "" ,
69
71
"ref" : order_reference_xpath [0 ].text if order_reference_xpath else "" ,
70
72
"supplier" : supplier_dict ,
71
73
"company" : customer_dict ,
72
- "despatch_advice_type_code" : despatch_advice_type_code_xpath [0 ].text
73
- if len (despatch_advice_type_code_xpath ) > 0
74
- else "" ,
74
+ "despatch_advice_type_code" : (
75
+ despatch_advice_type_code_xpath [0 ].text
76
+ if len (despatch_advice_type_code_xpath ) > 0
77
+ else ""
78
+ ),
75
79
"date" : len (date_xpath ) and date_xpath [0 ].text ,
76
80
"estimated_delivery_date" : len (estimated_delivery_date_xpath )
77
81
and estimated_delivery_date_xpath [0 ].text ,
@@ -125,6 +129,25 @@ def parse_ubl_despatch_advice_line(self, line, ns):
125
129
"uom" : {"unece_code" : qty_xpath [0 ].attrib .get ("unitCode" )},
126
130
"backorder_qty" : backorder_qty ,
127
131
}
132
+
133
+ package_id_xpath = line .xpath (
134
+ "cac:Shipment/cac:TransportHandlingUnit/cac:ActualPackage/cbc:ID" ,
135
+ namespaces = ns ,
136
+ )
137
+ package_type_xpath = line .xpath (
138
+ "cac:Shipment/cac:TransportHandlingUnit/cbc:TransportHandlingUnitTypeCode" ,
139
+ namespaces = ns ,
140
+ )
141
+ package_weight_xpath = line .xpath (
142
+ "cac:Shipment/cac:GrossWeightMeasure/cbc:Measure" , namespaces = ns
143
+ )
144
+ if package_id_xpath or package_type_xpath :
145
+ res_line ["package" ] = {
146
+ "name" : package_id_xpath [0 ].text if package_id_xpath else "" ,
147
+ "type" : package_type_xpath [0 ].text if package_type_xpath else "" ,
148
+ "weight" : package_weight_xpath [0 ].text if package_weight_xpath else "" ,
149
+ }
150
+
128
151
defaults = self .env .context .get ("despatch_advice_import__default_vals" , {}).get (
129
152
"lines" , {}
130
153
)
@@ -141,9 +164,11 @@ def ubl_parse_party(self, party_node, ns):
141
164
142
165
vat_xpath = party_node .xpath ("cac:PartyIdentification/cbc:ID" , namespaces = ns )
143
166
partner_dict = {
144
- "vat" : vat_xpath [0 ].text
145
- if vat_xpath and vat_xpath [0 ].attrib .get ("schemeName" ).upper ()
146
- else False ,
167
+ "vat" : (
168
+ vat_xpath [0 ].text
169
+ if vat_xpath and vat_xpath [0 ].attrib .get ("schemeName" ).upper ()
170
+ else False
171
+ ),
147
172
"name" : partner_name_xpath [0 ].text ,
148
173
}
149
174
address_xpath = party_node .xpath ("cac:PostalAddress" , namespaces = ns )
0 commit comments