Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: WMS Accounting

Entity: stock.quant

Compute Method: _compute_value

View 18.0 View 20.0
Inputs Method Outputs
  • company_id
  • company_id.currency_id
  • location_id
  • product_id
  • quantity
  • product_id.uom_id
  • product_id.uom_id.rounding
  • product_id.lot_valuated
  • lot_id
- """ (Product.value_svl / Product.quantity_svl) * quant.quantity, i.e. average unit cost * on hand qty
-         """
self.fetch(['company_id', 'location_id', 'owner_id', 'product_id', 'quantity', 'lot_id'])
self.value = 0
for quant in self:
-             quant.currency_id = quant.company_id.currency_id
            if not quant.location_id or not quant.product_id or\
                    not quant.location_id._should_be_valued() or\
                    quant._should_exclude_for_valuation() or\
-                     float_is_zero(quant.quantity, precision_rounding=quant.product_id.uom_id.rounding):
+                     quant.product_id.uom_id.is_zero(quant.quantity):
                continue
            if quant.product_id.lot_valuated:
-                 quantity = quant.lot_id.with_company(quant.company_id).quantity_svl
-                 value_svl = quant.lot_id.with_company(quant.company_id).value_svl
+                 quantity = quant.lot_id.with_company(quant.company_id).product_qty
+                 value = quant.lot_id.with_company(quant.company_id).total_value
            else:
-                 quantity = quant.product_id.with_company(quant.company_id).quantity_svl
-                 value_svl = quant.product_id.with_company(quant.company_id).value_svl
-             if float_is_zero(quantity, precision_rounding=quant.product_id.uom_id.rounding):
+                 quantity = quant.product_id.with_company(quant.company_id)._with_valuation_context().qty_available
+                 value = quant.product_id.with_company(quant.company_id).total_value
+             if quant.product_id.uom_id.is_zero(quantity):
                continue
-             quant.value = quant.quantity * value_svl / quantity
+             quant.value = quant.quantity * value / quantity
  • value
  • currency_id

Back to entity