I just saw the following operation on lots (with stock_lot_unit module).
It is possible to ship more quantity than the quantity in the lot if the quantities are spread over several shipments. For example on a lot of 10 products, it is possible to send 7 products on shipment 1 and 9 products on shipment 2.
Is this the expected behavior?
Well it is a side effect of the implementation.
The documentation is clear on what does a lot unit.
And just like you are allowed to create negative stock value, you can do the same for quantity of a unit.
I think that the contents of the doc can be subject to interpretation and this is the reason for this confirmation request (but my English is not good enough to make a better proposal)
I don’t know the reasons that made this possible, but in both cases it’s intellectually bizarre, don’t you think?
No the system should not prevent entering correct value (what physically the user is doing) in case there was mistakes in the past.
I come back to the initial question, would it be possible to consider a mechanism such as assignment (on delivery notes) which check the usable (remaining) quantity on the lot?
But the assignation process by default does not tell you which lot is assigned (because in Tryton all instances of a product are the same). So the lot is the user input to say I pick this particular instance.
Now with Issue 9480: Fill grouping values when assigning move - Tryton issue tracker it is possible to configure the assignation process to fill lot number. In this case it always pick available lot anyway.
Here’s what we’ve done to add lot automatically when doing “Assign”.
It’s a patch for module stock_lot:
diff -r 3567f0227f6f stock.py --- a/stock.py Fri Aug 14 14:21:02 2020 +0200 +++ b/stock.py Fri Sep 18 10:35:41 2020 +0200 @@ -128,6 +128,10 @@ product=self.product.rec_name)) @classmethod + def assign_try(cls, moves, with_childs=True, grouping=('product', 'lot',)): + return super().assign_try(moves, with_childs, grouping) + + @classmethod def validate(cls, moves): super(Move, cls).validate(moves) for move in moves:
Well you do not need to patch the module. You can just extend Move to override the assign_try method and pass the proper grouping value.
Hum, that’s what is done with my code
I’m wondering if we should make this more user friendly. Allowing the user to configure the grouping values in stock configuration.
I think it was already discussed. There are so many different needs that it can not be a simple configuration. Lot assignation can be only for a sets of products, it can depend on the location or it can depend on the operation etc.
This is the same as for picking strategy, we have just to left the possibility to implement it.