I think the current proposal is too strict by defining the serial property only on the product.
Indeed I think we could have serial number for a pack of products. This will be expressed by a different unit of measure with still 1 as quantity.
The same product could have different kind of serial number, one when it was in a bigger packaging and one when it is unpacked.
For this, I think that the serial property should be stored on the lot itself.
This serial property will be stored as a UoM which represent the total quantity that contains the lot. This way the constraints will be that a move with this lot can not have a quantity greater than the 1 UoM of the lot (and for shipment constraint the sum can not be greater).
The serial case will be managed by using the smallest UoM with 0 digits and rounding of 1.
As serial number will be just a particular case of this module, I think we should have a better name. I propose stock_lot_unit
Failed example:
lot = Lot(number='00001', product=product)
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1315, in __run
compileflags, 1) in test.globs
File "_lot_unit.rst[51]>", line 1, in
lot = Lot(number='00001', product=product)
File "/home/kpreisler/fab_venv/projects/trytondev/proteus/proteus/__init__.py", line 726, in __init__
setattr(self, field_name, value)
File "/home/kpreisler/fab_venv/projects/trytondev/proteus/proteus/__init__.py", line 265, in __set__
super(Many2OneDescriptor, self).__set__(instance, value)
File "/home/kpreisler/fab_venv/projects/trytondev/proteus/proteus/__init__.py", line 129, in __set__
instance._on_change([self.name])
File "/home/kpreisler/fab_venv/projects/trytondev/proteus/proteus/__init__.py", line 1094, in _on_change
changes = getattr(self._proxy, 'on_change')(values, names, context)
File "/home/kpreisler/fab_venv/projects/trytondev/proteus/proteus/config.py", line 185, in __call__
result = rpc.result(meth(inst, *args, **kwargs))
File "/home/kpreisler/fab_venv/projects/trytondev/trytond/trytond/model/modelview.py", line 683, in on_change
method()
File "/home/kpreisler/fab_venv/projects/trytondev/trytond/trytond/model/modelview.py", line 84, in wrapper
result = func(self, *args, **kwargs)
File "/home/kpreisler/fab_venv/projects/trytondev/trytond/trytond/model/fields/field.py", line 113, in wrapper
return func(self, *args, **kwargs)
File "/home/kpreisler/fab_venv/projects/trytondev/trytond/trytond/modules/stock_lot_unit/stock.py", line 50, in on_change_product
if self.product and self.product.lot_unit:
File "/home/kpreisler/fab_venv/projects/trytondev/trytond/trytond/model/modelstorage.py", line 1226, in __getattr__
raise AttributeError('"%s" has no attribute "%s"' % (self, name))
AttributeError: "product.product,1" has no attribute "lot_unit"
With the new counting wizard it is currently possible to add a quantity that is higher than the quantity of the selected lot. And it is possible to select a product that requires a lot and to add any quantity without selecting a lot. Both should be not possible.
It is still possible to enter a quantity for a lot that is higher than the defined quantity on the lot. And there is no error raised on validation of the inventory.
The validation does not raise an error if you add to a lot that already has a quantity of 1 in stock another quantity of 1 (expected quantity: 1, quantity: 2, lot_unit: 1 unit) as in this case the quantity of the stock move is not greater than the lot unit.