sr1871 / fedex-python

MIT License
0 stars 0 forks source link

Issue with multiple packages (send request one by one) for Label. #3

Open NirajSN opened 3 years ago

NirajSN commented 3 years ago

First Request:

ship_timestamp='2021-03-04T01:03:49+00:00' dropoff_type=<DropoffTypeEnum.REGULAR_PICKUP: 'REGULAR_PICKUP'> packaging_type=<PackagingTypeEnum.YOUR_PACKAGING: 'YOUR_PACKAGING'> service_type=<ShipServiceTypeEnum.PRIORITY_OVERNIGHT: 'PRIORITY_OVERNIGHT'> shipper=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='My Company (San Francisco)', phone_number='+1 (650) 691-3277 ', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='info@yourcompany.com'), address=Address(street_lines=['250 Executive Park Blvd, Suite 3400', ''], city='San Francisco', state_or_province_code='CA', postal_code='94134', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) recipient=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='Lumber Inc', phone_number='(828)-316-0593', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='lumber-inv92@example.com'), address=Address(street_lines=['1337 N San Joaquin St', ''], city='Stockton', state_or_province_code='CA', postal_code='95202', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) total_weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.565671')) package_count=1 shipping_charges_payment=ShippingChargesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))) requested_package_line_items=RequestedPackageLineItemBase(sequence=None, weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('1.51')), dimensions=Dimensions(length=20, height=20, width=20, units=<LinearUnits.IN: 'IN'>), customer_references=CustomerReference(customer_reference_type=<CustomerReferenceType.CUSTOMER_REFERENCE: 'CUSTOMER_REFERENCE'>, value='WH/OUT/00019'), sequence_number=1) preferred_currency=<CurrencyCodeEnum.EURO: 'EUR'> label_specification=LabelSpecification(label_format_type=<LabelFormatTypeEnum.COMMON2D: 'COMMON2D'>, image_type=<ImageTypeEnum.PDF: 'PDF'>, label_stock_type=<LabelStockTypeEnum.PAPER_LETTER: 'PAPER_LETTER'>, label_printing_orientation=<LabelPrintingOrientationEnum.TOP_EDGE_OF_TEXT_FIRST: 'TOP_EDGE_OF_TEXT_FIRST'>, label_order=<LabelOrderEnum.SHIPPING_LABEL_FIRST: 'SHIPPING_LABEL_FIRST'>) rate_request_types=<RateRequestTypeEnum.PREFERRED: 'PREFERRED'> master_tracking_id=None customs_clearance_detail=None

Second Request

ship_timestamp='2021-03-04T01:03:49+00:00' dropoff_type=<DropoffTypeEnum.REGULAR_PICKUP: 'REGULAR_PICKUP'> packaging_type=<PackagingTypeEnum.YOUR_PACKAGING: 'YOUR_PACKAGING'> service_type=<ShipServiceTypeEnum.PRIORITY_OVERNIGHT: 'PRIORITY_OVERNIGHT'> shipper=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='My Company (San Francisco)', phone_number='+1 (650) 691-3277 ', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='info@yourcompany.com'), address=Address(street_lines=['250 Executive Park Blvd, Suite 3400', ''], city='San Francisco', state_or_province_code='CA', postal_code='94134', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) recipient=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='Lumber Inc', phone_number='(828)-316-0593', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='lumber-inv92@example.com'), address=Address(street_lines=['1337 N San Joaquin St', ''], city='Stockton', state_or_province_code='CA', postal_code='95202', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) total_weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.565671')) package_count=1 shipping_charges_payment=ShippingChargesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))) requested_package_line_items=RequestedPackageLineItemBase(sequence=None, weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('4.51')), dimensions=Dimensions(length=0, height=0, width=0, units=<LinearUnits.IN: 'IN'>), customer_references=CustomerReference(customer_reference_type=<CustomerReferenceType.CUSTOMER_REFERENCE: 'CUSTOMER_REFERENCE'>, value='WH/OUT/00019'), sequence_number=2) preferred_currency=<CurrencyCodeEnum.EURO: 'EUR'> label_specification=LabelSpecification(label_format_type=<LabelFormatTypeEnum.COMMON2D: 'COMMON2D'>, image_type=<ImageTypeEnum.PDF: 'PDF'>, label_stock_type=<LabelStockTypeEnum.PAPER_LETTER: 'PAPER_LETTER'>, label_printing_orientation=<LabelPrintingOrientationEnum.TOP_EDGE_OF_TEXT_FIRST: 'TOP_EDGE_OF_TEXT_FIRST'>, label_order=<LabelOrderEnum.SHIPPING_LABEL_FIRST: 'SHIPPING_LABEL_FIRST'>) rate_request_types=<RateRequestTypeEnum.PREFERRED: 'PREFERRED'> master_tracking_id='794692529437' customs_clearance_detail=None

--- Got the error:

response = getattr(self.client.service, service_name)(**self._elements)

File "/usr/local/lib/python3.7/dist-packages/zeep/proxy.py", line 42, in call self._op_name, args, kwargs) File "/usr/local/lib/python3.7/dist-packages/zeep/wsdl/bindings/soap.py", line 132, in send return self.process_reply(client, operation_obj, response) File "/usr/local/lib/python3.7/dist-packages/zeep/wsdl/bindings/soap.py", line 194, in process_reply return self.process_error(doc, operation) File "/usr/local/lib/python3.7/dist-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error detail=fault_node.find('detail')) Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/opt/odoo/odoo/http.py", line 639, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/opt/odoo/odoo/http.py", line 315, in _handle_exception raise exception.with_traceback(None) from new_cause zeep.exceptions.Fault: Fault

sr1871 commented 3 years ago

Can you be more specific please? What is the difference between first request and second request?

NirajSN commented 3 years ago

Hi, Here, I have 3 different/same type of packages for generating the labels with unique master track id. You can see the different only in requested_package_line_items parameter.

In-case some things is wrong in my request or parameter, please guide me on that.

let me share all requests: (as an given example with dummy master tracking id, highlighted parameters where you can find difference of the request).

1). ship_timestamp='2021-03-05T05:39:06+00:00' dropoff_type=<DropoffTypeEnum.REGULAR_PICKUP: 'REGULAR_PICKUP'> packaging_type=<PackagingTypeEnum.YOUR_PACKAGING: 'YOUR_PACKAGING'> service_type=<ShipServiceTypeEnum.INTERNATIONAL_PRIORITY: 'INTERNATIONAL_PRIORITY'> shipper=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='My Company (San Francisco)', phone_number='+1 (650) 691-3277 ', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='info@yourcompany.com'), address=Address(street_lines=['250 Executive Park Blvd, Suite 3400', ''], city='San Francisco', state_or_province_code='CA', postal_code='94134', urbanization_code=None, country_code='DE', country_name=None, residential=None, geographic_coordinates=None)) recipient=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='Lumber Inc', phone_number='(828)-316-0593', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='lumber-inv92@example.com'), address=Address(street_lines=['1337 N San Joaquin St', ''], city='Stockton', state_or_province_code='CA', postal_code='95202', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) total_weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.565671')) package_count=1 shipping_charges_payment=ShippingChargesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))) requested_package_line_items=RequestedPackageLineItemBase(sequence=None, weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('1.51')), dimensions=Dimensions(length=20, height=20, width=20, units=<LinearUnits.IN: 'IN'>), customer_references=CustomerReference(customer_reference_type=<CustomerReferenceType.CUSTOMER_REFERENCE: 'CUSTOMER_REFERENCE'>, value='WH/OUT/00019'), sequence_number=1) preferred_currency=<CurrencyCodeEnum.EURO: 'EUR'> label_specification=LabelSpecification(label_format_type=<LabelFormatTypeEnum.COMMON2D: 'COMMON2D'>, image_type=<ImageTypeEnum.PDF: 'PDF'>, label_stock_type=<LabelStockTypeEnum.PAPER_LETTER: 'PAPER_LETTER'>, label_printing_orientation=<LabelPrintingOrientationEnum.TOP_EDGE_OF_TEXT_FIRST: 'TOP_EDGE_OF_TEXT_FIRST'>, label_order=<LabelOrderEnum.SHIPPING_LABEL_FIRST: 'SHIPPING_LABEL_FIRST'>) rate_request_types=<RateRequestTypeEnum.PREFERRED: 'PREFERRED'> master_tracking_id=None customs_clearance_detail=CustomsClearanceDetail(duties_payment=DutiesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))), document_content='NON_DOCUMENTS', customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('7597.07')), commodities=[Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('0.110231')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('5.0'), quantity_units='EA', harmonizedCode=''), Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.455439999999996')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('8.0'), quantity_units='EA', harmonizedCode='')])

2). ship_timestamp='2021-03-05T05:39:06+00:00' dropoff_type=<DropoffTypeEnum.REGULAR_PICKUP: 'REGULAR_PICKUP'> packaging_type=<PackagingTypeEnum.YOUR_PACKAGING: 'YOUR_PACKAGING'> service_type=<ShipServiceTypeEnum.INTERNATIONAL_PRIORITY: 'INTERNATIONAL_PRIORITY'> shipper=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='My Company (San Francisco)', phone_number='+1 (650) 691-3277 ', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='info@yourcompany.com'), address=Address(street_lines=['250 Executive Park Blvd, Suite 3400', ''], city='San Francisco', state_or_province_code='CA', postal_code='94134', urbanization_code=None, country_code='DE', country_name=None, residential=None, geographic_coordinates=None)) recipient=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='Lumber Inc', phone_number='(828)-316-0593', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='lumber-inv92@example.com'), address=Address(street_lines=['1337 N San Joaquin St', ''], city='Stockton', state_or_province_code='CA', postal_code='95202', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) total_weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.565671')) package_count=1 shipping_charges_payment=ShippingChargesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))) requested_package_line_items=RequestedPackageLineItemBase(sequence=None, weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('4.51')), dimensions=Dimensions(length=20, height=20, width=20, units=<LinearUnits.IN: 'IN'>), customer_references=CustomerReference(customer_reference_type=<CustomerReferenceType.CUSTOMER_REFERENCE: 'CUSTOMER_REFERENCE'>, value='WH/OUT/00019'), sequence_number=2) preferred_currency=<CurrencyCodeEnum.EURO: 'EUR'> label_specification=LabelSpecification(label_format_type=<LabelFormatTypeEnum.COMMON2D: 'COMMON2D'>, image_type=<ImageTypeEnum.PDF: 'PDF'>, label_stock_type=<LabelStockTypeEnum.PAPER_LETTER: 'PAPER_LETTER'>, label_printing_orientation=<LabelPrintingOrientationEnum.TOP_EDGE_OF_TEXT_FIRST: 'TOP_EDGE_OF_TEXT_FIRST'>, label_order=<LabelOrderEnum.SHIPPING_LABEL_FIRST: 'SHIPPING_LABEL_FIRST'>) rate_request_types=<RateRequestTypeEnum.PREFERRED: 'PREFERRED'> master_tracking_id='123123123' customs_clearance_detail=CustomsClearanceDetail(duties_payment=DutiesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))), document_content='NON_DOCUMENTS', customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('7597.07')), commodities=[Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('0.110231')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('5.0'), quantity_units='EA', harmonizedCode=''), Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.455439999999996')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('8.0'), quantity_units='EA', harmonizedCode='')])

3). ship_timestamp='2021-03-05T05:39:06+00:00' dropoff_type=<DropoffTypeEnum.REGULAR_PICKUP: 'REGULAR_PICKUP'> packaging_type=<PackagingTypeEnum.YOUR_PACKAGING: 'YOUR_PACKAGING'> service_type=<ShipServiceTypeEnum.INTERNATIONAL_PRIORITY: 'INTERNATIONAL_PRIORITY'> shipper=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='My Company (San Francisco)', phone_number='+1 (650) 691-3277 ', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='info@yourcompany.com'), address=Address(street_lines=['250 Executive Park Blvd, Suite 3400', ''], city='San Francisco', state_or_province_code='CA', postal_code='94134', urbanization_code=None, country_code='DE', country_name=None, residential=None, geographic_coordinates=None)) recipient=ContactAddress(account_number=None, contact=Contact(contact_id=None, person_name='', title=None, company_name='Lumber Inc', phone_number='(828)-316-0593', phone_extension=None, toll_free_phone_number=None, pager_number=None, fax_number=None, eMail_address='lumber-inv92@example.com'), address=Address(street_lines=['1337 N San Joaquin St', ''], city='Stockton', state_or_province_code='CA', postal_code='95202', urbanization_code=None, country_code='US', country_name=None, residential=None, geographic_coordinates=None)) total_weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.565671')) package_count=1 shipping_charges_payment=ShippingChargesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))) requested_package_line_items=RequestedPackageLineItemBase(sequence=None, weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('6.03')), dimensions=Dimensions(length=0, height=0, width=0, units=<LinearUnits.IN: 'IN'>), customer_references=CustomerReference(customer_reference_type=<CustomerReferenceType.CUSTOMER_REFERENCE: 'CUSTOMER_REFERENCE'>, value='WH/OUT/00019'), sequence_number=3) preferred_currency=<CurrencyCodeEnum.EURO: 'EUR'> label_specification=LabelSpecification(label_format_type=<LabelFormatTypeEnum.COMMON2D: 'COMMON2D'>, image_type=<ImageTypeEnum.PDF: 'PDF'>, label_stock_type=<LabelStockTypeEnum.PAPER_LETTER: 'PAPER_LETTER'>, label_printing_orientation=<LabelPrintingOrientationEnum.TOP_EDGE_OF_TEXT_FIRST: 'TOP_EDGE_OF_TEXT_FIRST'>, label_order=<LabelOrderEnum.SHIPPING_LABEL_FIRST: 'SHIPPING_LABEL_FIRST'>) rate_request_types=<RateRequestTypeEnum.PREFERRED: 'PREFERRED'> master_tracking_id='123123123' customs_clearance_detail=CustomsClearanceDetail(duties_payment=DutiesPayment(payment_type=<PaymentTypeEnum.SENDER: 'SENDER'>, payor=Payor(responsible_party=ContactAddress(account_number='601356805', contact=None, address=None))), document_content='NON_DOCUMENTS', customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('7597.07')), commodities=[Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('0.110231')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('5.0'), quantity_units='EA', harmonizedCode=''), Commodity(unit_price=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), customs_value=CustomsValue(currency=<CurrencyCodeEnum.EURO: 'EUR'>, amount=Decimal('584.39')), number_of_pieces=Decimal('1'), country_of_manufacture='DE', weight=Weight(units=<WeightUnits.LB: 'LB'>, value=Decimal('26.455439999999996')), description='Customizable Desk (CONFIG)', purpose=None, quantity=Decimal('8.0'), quantity_units='EA', harmonizedCode='')])

I am not sure it is coming from your library or zeep library.

sr1871 commented 3 years ago

So if I understand right, you are trying to send more than one package at the same ship?

If that its right, trying to return a list of package on requested_package_line_items requested_package_line_items = [RequestedPackageLineItemBase(...), RequestedPackageLineItemBase(...) ...]

NirajSN commented 3 years ago

Yes, this is right request for rate of shipment(Price). But not for shipment (label)

For shipment (generate label), only one package should allow during send request. otherwise it will give error like "Only one package should be allow for generating shipment(label)."