Skip to content

Better management and abstracted code for shipping API's such as Ship Engine

License

Notifications You must be signed in to change notification settings

RogueNAND/odoo-ship-api

Repository files navigation

Odoo Shipping API

THIS MODULE IS CURRENTLY IN DEVELOPMENT AND IS MISSING MANY KEY FEATURES! USE AT YOUR OWN RISK UNTIL FURTHER NOTICE!

This module is intended to be a development platform for connecting multiple shipping API's.

This module is compatible with the 'product_dimension' module from OCA/product-attribute, but is intended to replace its functionality after installation. Once 'delivery_api' is installed, you may uninstall 'product_dimension'

If you are not already using the 'product_dimension' module to manage dimensions, ALL PRODUCT VOLUME INFORMATION WILL BE LOST! (weight information is safe)

Supported API's

Currently only Ship Engine is supported, but adding your own shipping api should be trivial.

  • Ship Engine
    • Address Validation
    • LTL (Less then TruckLoad) shipments

It is recommended to verify your warehouse addresses to ensure accuracy

Required Methods

All required methods are abstracted out into the database model 'delivery.carrier.api'.

from odoo import api, fields, models

class DeliveryCarrierApi(models.Model):
    _inherit = 'delivery.carrier.api'

    """ Replace SHIPPINGAPINAME with the name of your shipping integration"""
    
    def SHIPPINGAPINAME_sync(self):
        """ Grab carriers and their related services from the api
        
        Carriers and their services are automatically created, updated, or deleted as necessary from the provided information
        A warning will be shown to the user if any carriers or services are deleted
        
        returns list of dicts containing carrier information:
        [
            {
                'code': str; carrier identifier for this api
                'name': str; friendly carrier name
                'services': list of dicts containing service information [
                    {
                        'code': str; service identifier for this api
                        'name': str; friendly service name
                    }
                ]
            }
        ]
        """
        return
    
    def SHIPPINGAPINAME_supports(self):
        """ Define supported features for the implementation """
        self.supports_test_environment = True
        self.supports_address_validation = True
        self.supports_tracking = True
        self.supports_insurance = True
        self.supports_returns = True
        self.supports_ltl = True
    
    def SHIPPINGAPINAME_verify_address(self, name, company_name, phone, street, street2, city, state_code, zip, country_code):
        """ Verify an address with the shipping api
        Required if supports_address_validation == True
        
        If the shipping api does not suggest whether the address should be double-checked,
            you can call self.compare_address_diff() before deciding to return a 'res.partner.verify' record
        
        returns dict {
            'success': bool; is this a valid address
            'data': dict (optional); corrected address values; if omitted, the original values are used
            'user_confirm: bool (optional); request user to verify changes; if omitted, built-in diff detection is used
            'message': str (required if success==False) any warning or error messages
        }
        """
        return

    def SHIPPINGAPINAME_rate_estimate(self, from_partner_id, to_partner_id, length, width, height, weight, active_service_ids):
        """ Get rates for all active services
        This method is automatically cached to eliminate repeated calls
        
        returns:
        - dict where key=int(service_id) and value=tuple(price, warning_message, error_message)
            {
                1: (5.76, "", ""),
                2: (10.29, "Surcharge may apply to recipient", ""),
                3: (0, "", "Package size too large"),
            }
        """
        return

TODO:

  • Proper multi-currency support
  • Website user should be able to confirm major address changes
  • Identify on Shipping API form view whether it's globally set as 'Test' or 'Production'
  • Possibly cache rates outside of delivery_api
  • Write tests
  • Better management of dimensions when product has multiple varients

About

Better management and abstracted code for shipping API's such as Ship Engine

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages