Automatically assigning shipments

Currently all the customer shipments are created in the “Waiting” state and the end user should user the assign button to try if the shipment products are available. This is a boring and repetitive task for end users which slow downs things.

I think it will be better to add a Wizard to assign all the shipments, so an user can give the order the system to try to assing all the existing shipments. This process will perform the following steps:

  • Search all waiting shipments scheduled for today.
  • Try to assign it one by one. If the assign_try fails it’s assigned moves will be reset back to draft (so it can be used for other shipments).

This process will be repetably executed for:

  • Supplier Return Shipments
  • Customer Shipments
  • Productions

After executing the wizard all the assigned records will be opened (in several tabs like we do for stock supply)

Of course it should be possible to customize the assignation records (domain and order) and model order by third party modules. So each company can update the process to it’s needs.

A cron action will be created to allow the execution of the process but withouth creating any task by default. This allow to schedule to be executed periodically (for example every night or whatever) and also keep the current workflow for existing users.


I think some use case would like to do partial delivery. So we should allow to specify some rules which trigger or not the deletion of non assigned moves.

I think we should allow to run for more than today. Some workflow may require to secure by assigning shipment longer in advance. So I would configure a delay for this and probably per type.

Also I think we should have a task to re-plannify past shipment.

I think it will be better to have one for each because the workflow may be quite different. For example in many companies, productions are scheduled per week but shipments are done every day.
Also I’m not fully sure about the necessity for automatic assignation for return shipments as they should be very rare.

Make sense. Probably using a percentage to define the minim required value (quantity * unit_price) that should be required to fully assign the shipment.

Ok so then I will break up everything into 4 tasks:

  • Replan past shipments.
  • Assign Customer Shipments
  • Assign Internal Shipments
  • Assign Productions

And then we should be able to define a delay for each assign task.

This will allow the company to define workflows by combining the scheduling of each task.

I’ve created Issue 9264: Allow to replan past shipments - Tryton issue tracker which simplments this for shipments and also for productions.

I think we should keep the current assigned state for shipments to indicate that somebody is working on them.

So this task should work on the move of this documents but never assign the shipments.

So we need a way to show to the user all the shipments that are “Available”. I think this should be a functional field based on a configurable threshold (by default 1.0) per shipment type. If the percentage is higher than the threshold the shipment is ready. If the shipment is keep the assignation of the moves is keep.

Then we should add an action domain on shipments to show the “Available” one so the user can easly find the shipments that are ready to work after the move assignation.

I do not see how the percentage will be computed.
Indeed I think there are some rules like all products are available or some are available. And we should allow to assign the shipment depending on the configuration of the sale. The customer (or the company) may define the rule like ship only when complete and allow partial but with maximum 2 shipments etc.
So I think it can not be a function field but a real field that is updated by the cron task following the rules.

Ok, then we can keep it simple on base module by setting it to ready only if all the moves are assigned.

And each company should be able to extend a method that returns if the shipment is ready based on it’s own rules.

I think the default should be that at least on move can be assigned because we allow by default partial shipping.

I’ve filled Issue 9513: Add cron job to automatically assign shipments - Tryton issue tracker which implements the assignation automatism.