diff options
| author | Simon Lejeune <sle@openerp.com> | 2017-09-11 15:55:21 +0200 |
|---|---|---|
| committer | Simon Lejeune <sle@openerp.com> | 2017-09-12 10:50:04 +0200 |
| commit | d08b4407be3cf9b404087056a413fbdc9eecbd9d (patch) | |
| tree | f0bc89105d18826aef3e9b11167985a8d1d22fe2 /addons/web/static/src/js/widgets/debug_manager.js | |
| parent | bb8f7bf9c3ef6f924912682802f02b1638212231 (diff) | |
[REF] stock: `_get_available_qty` and tracked products
Suppose you have a product tracked by serial number. In your inventory,
you have two quants: -1 for serial1, +1 for serial2.
If you create a move for 1 product and try to run `action_assign`, it
didn't work before this patch because stock.move's
`_update_reserved_quantity` is guarded by a call to
an unstricted `_get_available_quantity` (unstricted meaning considering
all quants regardless of their lot_id/package_id/owner_id). This call
resulted in an available quantity of 0, thus the stock move could not be
reserved
To fix this issue, we patched `_get_available_quantity` so that it
rightly considers products of different lot_id as different products,
i.e. it returns an available quantity of +1 in the initial scenario. Of
course, we consider all quants of the same lot_id, i.e. if you have -1
for serial1 and +1 for serial2, the available quantity amounts to 0.
In another scenario, let's say we have only -1 serial1 in stock, if we
run `_get_available_quantity`, the method should return 0: nothing is
reservable. We continue this reasonment by returning 0 everytime the
available quantity is negative, tracked or not. This is probably what a
method named `_get_available_quantity` should have done since the
beginning.
There's only a single case where we need to know the quantity even if
it's negative: it's just after we move a quant to its destination
location. If this quant was tracked and resulted in a negative quant
(i.e. we moved something we didn't have), we try to compensate with an
untracked quant. In this special case, we do not want to ignore the
negative quants when calling `_get_available_quantity`. That's why we
introduce a new argument to this method. We could have added a new method
`_get_quantity` for clarity sake.
Diffstat (limited to 'addons/web/static/src/js/widgets/debug_manager.js')
0 files changed, 0 insertions, 0 deletions
