Shipments and Production assign_try() should work at document level
Currently shipments [1] and productions' [2] implementation of assign_try works as follows:
1. Tries to assign all stock moves of all documents (shipments or productions) supplied in batch
2. Sets all supplied documents as assigned if and only if all moves of all documents have been assigned
In my opinion this is not the expected behaviour and 2. should be changed to work as follows:
"Changes the state to 'assigned' of all documents that have all their moves in assigned state. No matter if stock moves of other documents have been assigned or if there where moves from the existing document already assigned."
Just to get a better understanding of the problem, this is more or less how I think Production's implementation of assign_try should look like IMHO:
def assign_try(cls, productions):
pool = Pool()
Move = pool.get('stock.move')
Move.assign_try([m for p in productions
for m in p.inputs])
to_assign = []
productions = cls.browse(productions)
for production in productions:
for input_ in production.inputs:
if input_.state == 'draft':
break
else:
to_assign.append(production)
cls.assign(to_assign)
[1] http://hg.tryton.org/modules/stock/file/tip/shipment.py#l837
[2] http://hg.tryton.org/modules/production/file/tip/production.py#l603