Please sign in to comment.
[FIX] stock: block any duplicate serial numbers
Serial numbers should be unique by design. There are currently some checks to empeach any duplication into transfers, inventory adjustements or production. However, a global constraint checking accross all quants is missing. Indeed, nothing blocks you to have the same serial number used in two sub locations of your stock. You can also deliver a tracked product then produce the same number. This commit adds a constraint at the stock move lines validation. After the creation of the quant (as it's tracked by serial number, it should always be a creation and not an update). We check that the serial number is not present elsewhere except in location 'supplier', 'production' and 'inventory. Those 3 last one are virtuals ones and the quantity is most of the time negatives. This commit also add a correction process for inventory adjutment. If a serial number is stored in loc1 and the inventory aims to change quantity to 1 for sn1 in loc2. We raise a correction wizard to warn the user there is a problem and to add in the inventory some line to balance the new stock moves. Ex: we produce sn1, we sell it to a customer. The quant situation is the following Production : -1 Customer : +1 We create an inventory adjustement to increase the quantity of sn1 in Stock. Without the commit, the situation whould have been Production : -1 Inventory : -1 Customer : +1 Stock : +1 What it does is inverting the first movement (stock -> customer) thanks to an inventory line The situation after the inventory is the following Production : -1 Stock : +1 Task : 1924758
- Loading branch information...
Showing with 480 additions and 17 deletions.
- +38 −0 addons/mrp/tests/test_order.py
- +34 −5 addons/mrp/tests/test_stock.py
- +1 −0 addons/stock/__manifest__.py
- +50 −0 addons/stock/models/stock_inventory.py
- +47 −0 addons/stock/models/stock_move_line.py
- +0 −6 addons/stock/models/stock_quant.py
- +1 −0 addons/stock/tests/common.py
- +63 −2 addons/stock/tests/test_inventory.py
- +163 −1 addons/stock/tests/test_move2.py
- +6 −3 addons/stock/views/stock_inventory_views.xml
- +1 −0 addons/stock/wizard/__init__.py
- +51 −0 addons/stock/wizard/stock_duplicate_warning.py
- +25 −0 addons/stock/wizard/stock_duplicate_warning_views.xml
Oops, something went wrong.