def action_cancel_shipment(self): if not self.track_number: return False if self.debug_mode == 'r': client, header = get_my_client(sandbox=False) else: client, header = get_my_client() res = client.service.printLabel(header, self.track_number) res = self.procc_res(res) self.rm_state = 'canceled' return True
def action_cancel_shipment(self): if not self.track_number: return False if self.debug_mode=='r': client, header =get_my_client(sandbox=False) else: client, header =get_my_client() res= client.service.printLabel(header, self.track_number) res=self.procc_res(res) self.rm_state='canceled' return True
def action_get_label(self): if not self.track_number: return False if self.debug_mode=='r': client, header =get_my_client(sandbox=False) else: client, header =get_my_client() res= client.service.printLabel(header, self.track_number) res=self.procc_res(res) self.label1=res.label self.label1_name=self._name.replace('.','-')+'-'+str(self.id)+'.pdf' return True
def action_get_label(self): if not self.track_number: return False if self.debug_mode == 'r': client, header = get_my_client(sandbox=False) else: client, header = get_my_client() res = client.service.printLabel(header, self.track_number) res = self.procc_res(res) self.label1 = res.label self.label1_name = self._name.replace('.', '-') + '-' + str( self.id) + '.pdf' return True
def action_send_to_server(self): if self._name == 'sale.order': self.recipient_id = self.partner_shipping_id if self.debug_mode == 'r': client, header = get_my_client(sandbox=False) else: client, header = get_my_client() requestedShipment = {} if self.service_type_id.code == 'R': #requestedShipment['shipmentType']= requestedShipment['shipmentType'] = {'code': 'Return'} else: #requestedShipment['shipmentType']='Delivery' requestedShipment['shipmentType'] = {'code': 'Delivery'} if self.service_occurence: requestedShipment['serviceOccurrence'] = self.service_occurence requestedShipment['serviceType'] = {'code': self.service_type_id.code} requestedShipment['serviceOffering'] = { 'serviceOfferingCode': { 'code': self.offering_code_id.service_offering_code } } if self.service_format_id: requestedShipment['serviceFormat'] = { 'serviceFormatCode': { 'code': self.service_format_id.code } } if self.shipping_date: requestedShipment['shippingDate'] = self.shipping_date #Contact block recipientContact = {} recipientContact['name'] = self.recipient_id.name if self.recipient_id.phone: #TODO ph = { 'countryCode': '0044', 'telephoneNumber': '07801123456', } recipientContact['telephoneNumber'] = ph if self.recipient_id.email: recipientContact['electronicAddress'] = { 'electronicAddress': self.recipient_id.email } #End Contact block requestedShipment['recipientContact'] = recipientContact #Address block recipientAddress = {} recipientAddress['addressLine1'] = self.recipient_id.street if self.recipient_id.street2: recipientAddress['addressLine2'] = self.recipient_id.street2 recipientAddress['postTown'] = self.recipient_id.city recipientAddress['postcode'] = self.recipient_id.zip if self.recipient_id.country_id: recipientAddress['country'] = { 'countryCode': { 'code': self.recipient_id.country_id.code } } requestedShipment['recipientAddress'] = recipientAddress # END Address block requestedShipment['senderReference'] = 'odoo' + self._name + str( self.id) # Weight block weight = { 'value': self.weight, 'unitOfMeasure': { 'unitOfMeasureCode': { 'code': 'g' } } } #Inrernational block if self.service_type_id.code == 'I': parcel = {} parcel['weight'] = weight requestedShipment['internationalInfo'] = { 'parcels': { 'parcel': parcel } } else: item = {} item['numberOfItems'] = 1 item['weight'] = weight off = {} off['itemID'] = '2000001' off['status'] = {'status': {'statusCode': ''}} off['offlineShipments'] = off #End requestedShipment['items'] = {'item': item} #Send Request res = client.service.createShipment(header, requestedShipment) res = self.procc_res(res) #_logger.warn('RM API PROCC res %s' % str(res.__dict__)) self.req_rm_state = res.completedShipmentInfo.status.status.statusCode.code self.track_number = res.completedShipmentInfo.allCompletedShipments.completedShipments[ 0].shipments[0].shipmentNumber[0] self.rm_state = 'registered' self.action_get_label() return True
def action_send_to_server(self): if self._name=='sale.order': self.recipient_id=self.partner_shipping_id if self.debug_mode=='r': client, header =get_my_client(sandbox=False) else: client, header =get_my_client() requestedShipment={} if self.service_type_id.code=='R': #requestedShipment['shipmentType']= requestedShipment['shipmentType']={'code':'Return'} else: #requestedShipment['shipmentType']='Delivery' requestedShipment['shipmentType']={'code':'Delivery'} if self.service_occurence: requestedShipment['serviceOccurrence']=self.service_occurence requestedShipment['serviceType']={'code':self.service_type_id.code} requestedShipment['serviceOffering']={'serviceOfferingCode':{'code':self.offering_code_id.service_offering_code}} if self.service_format_id: requestedShipment['serviceFormat']={'serviceFormatCode':{'code':self.service_format_id.code}} if self.shipping_date: requestedShipment['shippingDate']=self.shipping_date #Contact block recipientContact={} recipientContact['name']=self.recipient_id.name if self.recipient_id.phone: #TODO ph={'countryCode':'0044', 'telephoneNumber':'07801123456', } recipientContact['telephoneNumber']=ph if self.recipient_id.email: recipientContact['electronicAddress']={'electronicAddress':self.recipient_id.email} #End Contact block requestedShipment['recipientContact']=recipientContact #Address block recipientAddress={} recipientAddress['addressLine1']=self.recipient_id.street if self.recipient_id.street2: recipientAddress['addressLine2']=self.recipient_id.street2 recipientAddress['postTown']=self.recipient_id.city recipientAddress['postcode']=self.recipient_id.zip if self.recipient_id.country_id: recipientAddress['country']={'countryCode':{'code':self.recipient_id.country_id.code}} requestedShipment['recipientAddress']=recipientAddress # END Address block requestedShipment['senderReference']='odoo'+self._name+ str(self.id) # Weight block weight={ 'value':self.weight, 'unitOfMeasure':{'unitOfMeasureCode':{'code':'g'}} } #Inrernational block if self.service_type_id.code=='I': parcel={} parcel['weight']=weight requestedShipment['internationalInfo']={'parcels':{'parcel':parcel}} else: item={} item['numberOfItems']=1 item['weight']=weight off={} off['itemID']='2000001' off['status']={'status':{'statusCode':''}} off['offlineShipments']=off #End requestedShipment['items']={'item':item} #Send Request res= client.service.createShipment(header, requestedShipment) res=self.procc_res(res) #_logger.warn('RM API PROCC res %s' % str(res.__dict__)) self.req_rm_state=res.completedShipmentInfo.status.status.statusCode.code self.track_number=res.completedShipmentInfo.allCompletedShipments.completedShipments[0].shipments[0].shipmentNumber[0] self.rm_state='registered' self.action_get_label() return True
# -*- encoding: utf-8 -*- ############################################################################## # # ############################################################################## from rm_lib import get_my_client client, header = get_my_client() cancel_numbers = {'shipmentNumber': 'xxxx'} vals = {'cancelShipments': cancel_numbers} print client res = client.service.createShipment(header, {}) for curr in res.integrationFooter.errors: print curr[1][0]['errorCode'] print curr[1][0]['errorDescription']
# -*- encoding: utf-8 -*- ############################################################################## # # ############################################################################## from rm_lib import get_my_client client, header =get_my_client() cancel_numbers={'shipmentNumber':'xxxx'} vals={ 'cancelShipments':cancel_numbers } print client res= client.service.createShipment(header, {}) for curr in res.integrationFooter.errors: print curr[1][0]['errorCode'] print curr[1][0]['errorDescription']