(self, pickings)
return result
Send the package to DHL Parcel
        :param pickings: A recordset of pickings
        :return list: A list of dictionaries although in practice it's
        called one by one and only the first item in the dict is taken. Due
        to this design, we have to inject vals in the context to be able to
        add them to the message.
Send the package to DHL Parcel
        :param pickings: A recordset of pickings
        :return list: A list of dictionaries although in practice it's
        called one by one and only the first item in the dict is taken. Due
        to this design, we have to inject vals in the context to be able to
        add them to the message.
Send the package to DHL Parcel : param pickings : A recordset of pickings : return list : A list of dictionaries although in practice it s called one by one and only the first item in the dict is taken . Due to this design we have to inject vals in the context to be able to add them to the message .
def dhl_parcel_send_shipping(self, pickings):
        """Send the package to DHL Parcel
        :param pickings: A recordset of pickings
        :return list: A list of dictionaries although in practice it's
        called one by one and only the first item in the dict is taken. Due
        to this design, we have to inject vals in the context to be able to
        add them to the message.
        """
        dhl_parcel_request = DhlParcelRequest(self)
        result = []
        for picking in pickings:
            vals = self._prepare_dhl_parcel_shipping(picking)
            response = dhl_parcel_request.create_shipment(vals)
            if not response:
                result.append(vals)
                continue
            vals["tracking_number"] = response.get("Tracking", "")
            # We post an extra message in the chatter with the rest of the response
            body = _(
                "DHL Parcel Shipping extra info:\n"
                "Origin: {}, Customer: {}, AWB: {}, LP: {}"
            ).format(
                response.get("Origin", "N/A"),
                response.get("Customer", "N/A"),
                response.get("AWB", "N/A"),
                response.get("LP", "N/A"),
            )
            attachment = []
            if response.get("Label"):
                attachment = [
                    (
                        "dhl_parcel_{}.pdf".format(response.get("Tracking", "")),
                        base64.b64decode(response.get("Label")),
                    )
                ]
            picking.message_post(body=body, attachments=attachment)
            result.append(vals)
        return result
def dhl_parcel_send_shipping ( self , pickings ) : dhl_parcel_request = DhlParcelRequest ( self ) result = [ ] for picking in pickings : vals = self . _prepare_dhl_parcel_shipping ( picking ) response = dhl_parcel_request . create_shipment ( vals ) if not response : result . append ( vals ) continue vals [ "tracking_number" ] = response . get ( "Tracking" , "" ) # We post an extra message in the chatter with the rest of the response body = _ ( "DHL Parcel Shipping extra info:\n" "Origin: {}, Customer: {}, AWB: {}, LP: {}" ) . format ( response . get ( "Origin" , "N/A" ) , response . get ( "Customer" , "N/A" ) , response . get ( "AWB" , "N/A" ) , response . get ( "LP" , "N/A" ) , ) attachment = [ ] if response . get ( "Label" ) : attachment = [ ( "dhl_parcel_{}.pdf" . format ( response . get ( "Tracking" , "" ) ) , base64 . b64decode ( response . get ( "Label" ) ) , ) ] picking . message_post ( body = body , attachments = attachment ) result . append ( vals ) return result