# Lasting internal shipment

**URL:** <https://discuss.tryton.org/t/lasting-internal-shipment/133>\
**Category:** Feature\
**Tags:** stock\
**Created:** [May 27, 2016, 10:33am UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133 "2016-05-27T10:33:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 27, 2016, 10:33am UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133/1 "2016-05-27T10:33:34Z")

</div>

# Rational

Some internal shipments can last for more than a day. It is the case for shipments between warehouses. So we need a way to make internal shipment in to steps.  
The duration of a shipment between two warehouses is not necessary the same as the reverse way. They could not use the same shipping service etc.

# Proposal

The duration of an internal shipment could be computed using a `MatchMixin` with criteria the warehouse of origin and the warehouse of destination.  
The internal shipment must be altered in case there is a duration.  
In this case the workflow must use an other path with one extra step _shipped_ between _assigned_ and _done_.  
The moves should also be split on the _waiting_ state into two sets where the _From_ and the _To_ is replaced by a _Transit_ location respectively. (The unique list should be restored if it goes back to _Draft_.)  
Of course the planned dates of each moves will be set according to the duration. Two new dates will be added to the shipment _Planned Start Date_ and _Effective Start Date_ (like for [issue5560](https://bugs.tryton.org/issue5560)) and they will be automatically computed using the duration.

I think this is a design that has the advantage of keeping the internal shipment inside a warehouse simple. But it allows complex multi-warehouse setup.  
The drawback is that in draft state, the forecast of the origin location will not be completly accurate but normally draft shipment should not stay long in draft.

# Implementation

> **[Lead time for internal shipments (#5587) · Issues · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/issues/5587)**
>
> See https://discuss.tryton.org/t/lasting-internal-shipment/133

---

<div class="post-metadata">

**Author:** ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)\
**Post date:** [May 27, 2016, 10:58am UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133/2 "2016-05-27T10:58:56Z")

</div>

> [@ced](#):
>
> The internal shipment must be altered in case the duration is greater than a day.

I see a lot of use cases where the transit last less than a day, but the internal shipment is between different physical locations, so the extra step shipped will be also usefull to know that the goods are in transit.

So maybe we instead of splitting when the duration is greater than a day, we can split when there is any duration. Of curse, the planned dates will only be updated when the delta is greather than a day.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 27, 2016, 11:01am UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133/3 "2016-05-27T11:01:49Z")

</div>

> [@pokoli](#):
>
> So maybe we instead of splitting when the duration is greater than a day, we can split when there is any duration.

Yes, this sounds like a more flexible design.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 27, 2016, 2:42pm UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133/4 "2016-05-27T14:42:04Z")

</div>

While implementing, I think I will just compare _Planned Date_ and _Planned Start Date_ to split or not. Those fields are now dates but in case could be changed in date time. I think it is wrong to store the delay (redundant) or used the configured delay to make the choice.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [October 19, 2017, 9:54am UTC](https://discuss.tryton.org/t/lasting-internal-shipment/133/5 "2017-10-19T09:54:35Z")

</div>


