When the 2 last moves of a stock.picking are assigned at the same
time by 2 jobs (different products both available), none of the
transaction will see that it is the last move to be assigned. As a
result, the picking will stay in state "confirmed" even if all its
moves are assigned.
Lock the stock.picking records when we call auto_assign.
If we have many pickings touched for the same product, the lock
can be quite large, so we may have to find a better option.
I could not write a test to exercise this, because we can't have 2
transactions being aware of it, even if we create the picking in demo
data as tests can be run during install.
Automatically check availability of stock moves when a move is set to "done".
It uses queue jobs to verify the availability in order to have a minimal impact
on the user operations.
The conditions to trigger the check are:
* A move is marked as done
* The destination locations of the move lines are internal
* The move doesn't have successors in a chain of moves
At this point, jobs are generated:
* One job per product
* Any move waiting for stock in a parent (or same) location of the internal
destination locations from the done move has its availability checked
Only one job is generated for an identical set of (product, locations).
When not all features are activated in inventory (locations, lots,
packages and owners) selecting a quant would raise an access error.
It is not possible to directly read the related fields, e.g
`self.lot_id`, because they are stored fields and have a group
restriction, so an access error would raise. To work around it,
we should access these fields from the quant:
`self.quant_id.lot_id`.
There are cases where auto-filling of qty_done of stock move line is not desirable.
e.g. you assign quants manually for some of the moves in a picking and not the others,
in such case you need to go over all the moves in the picking to either remove qty_done
or fill it in to proceed with the validation of the entire moves. Auto-fill behavior is
also troublesome when this function is used in a manufacturing order. i.e. having
qty_done of the component move live messes up the outcome of the production.