Drop shipment per customer location

Hi All,

One of our customer is using the sale_supply_drop_shipment module to directly send products from supplier to customer. When sending to another country they do not use the drop shipment but receive the product on it’s offices and send them to the country because they gave to prepare the customs documents to be able to import the products.

In this case tryton does not need to generate a drop shipment but only a supply on sale.

Anyone has found a similar use case? If yes, how did you solve it?

I guess it could be solved by adding a list of allowed countries for which the product supplier does drop shipping.
So get_purchase_request could be refactored to allow to extend the drop_shipment test. I guess it could be a method accepting more arguments like the shipment address.

Inded it can be created with a code like this:


    def get_purchase_request(self):
        "Do not set drop shipment for foreign countries"

        request = super().get_purchase_request()

        if request and getattr(request, 'customer', None):
            company_country = None
            for address in self.company.party.addresses:
                if address.country:
                    company_country = address.country
                    break
            shipment_country = self.sale.shipment_address.country
            if (company_country
                    and shipment_country
                    and shipment_country != company_country):
                request.customer = None
                request.delivery_address = None
        return request

But I’m wondering if this requirment is something more common due to the involment of customs

Such code is OK for customization but I think it is always better if we could provide a single place to customize a behavior. So here we have a single Boolean field which should be transformed into a function to allow extending the usage.

But as far as we require a customization on third party module I do not see which is the benefit of refactoring the base module to allow customization of drop shipment (but this may be unrelated to this feature)

It is to have a proper and central way to do it.
For me, it seems clear that a single boolean is too simple to manage the decision of doing a drop shipment or not.

I tend to agree here but the problem may be also for the supply_on_sale checkbox.

I’ve seen some cases where the company supplies on sale but may also have some spare stock for the product (I didn’t have the time to properly understand why they have stock) so in this case the supply on sale is only required when there is no stock.

For most of the cases I’ve found, the supplier does drop shipment for all of it’s products, so most of the time having to set the drop_shipment boolean flag on product supplier produces produces more errors than benefits. So probably moving the flag to the supplier will simplify the usage a little bit.

Also the need of having proper delivery_dates set (the product_supplier is not picked for drop shipment if lead_times are not set) is something that probably should also be simplified.

I’m not sure about which will be the best solution, but probably having a selection method to determine the supply method (with a proper default for it) wil make easier to support more cases.

This workflow is exactly the “not supply on sale”.

For me a selection will just add few more options when clearly the drop shipment case is much more complex than that. For example, you may want to supplier to do drop shipment inside the EU or in Benelux only etc. So clearly it must be a method which may allow to combine multiple criteria.