Skip to content

Commit

Permalink
[FIX] stock: unlink zero quants
Browse files Browse the repository at this point in the history
If you create a quant through the inventory mode of the list view and
you don't set a quantity, the quantity is null and the quant isn't
unlinked by _unlink_zero_quants.

Also consider null quantity as 0.

We don't have the issue for the reserved_quantity field since this one
is not nullable.

closes odoo#47983

Signed-off-by: Simon Lejeune (sle) <[email protected]>
  • Loading branch information
sle-odoo committed Mar 19, 2020
1 parent 2338f8e commit 08e4284
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/stock/models/stock_quant.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def _unlink_zero_quants(self):
"""
precision_digits = max(6, self.sudo().env.ref('product.decimal_product_uom').digits * 2)
# Use a select instead of ORM search for UoM robustness.
query = """SELECT id FROM stock_quant WHERE round(quantity::numeric, %s) = 0 AND round(reserved_quantity::numeric, %s) = 0;"""
query = """SELECT id FROM stock_quant WHERE (round(quantity::numeric, %s) = 0 OR quantity IS NULL) AND round(reserved_quantity::numeric, %s) = 0;"""
params = (precision_digits, precision_digits)
self.env.cr.execute(query, params)
quant_ids = self.env['stock.quant'].browse([quant['id'] for quant in self.env.cr.dictfetchall()])
Expand Down

0 comments on commit 08e4284

Please sign in to comment.