[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 a1eb000c93
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) <sle@openerp.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user