From 6b8a0beda65dce688ecd0ee34828097b67a13dab Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Thu, 11 Jul 2019 12:45:15 +0000 Subject: [PATCH] [FIX] stock: access error on stock.quant Usecase to reproduce: - Connect on demo user (inventory user) - Go on product page and click on stat button for 'quantity on hand' > AccessError on decimal.precision object due to commit a1eb000c93a5a64b3041c48ed9b1eaf3c03257d3 When the user click on 'report inventory' button it will garbage collect the remaining quants without quantity. In order to do it, it needs the precision rounding in order to have a rounding and do not let quant without significant quantity. closes odoo/odoo#34780 Signed-off-by: Simon Lejeune (sle) --- addons/stock/models/stock_quant.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 4c229a89304..14c6cc77aae 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -443,7 +443,7 @@ class StockQuant(models.Model): this method is often called in batch and each unlink invalidate the cache. We defer the calls to unlink in this method. """ - precision_digits = max(6, self.env.ref('product.decimal_product_uom').digits * 2) + 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;""" params = (precision_digits, precision_digits)