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

Module: Purchase Stock

Entity: product.product

Compute Method: _compute_suggested_quantity

Inputs Method Outputs
ctx = self.env.context
self.suggested_qty = 0
if ctx.get("suggest_based_on") == "actual_demand":
            for product in self:
                if product.virtual_available >= 0:
                    continue
                qty = - product.virtual_available * ctx.get("suggest_percent", 0) / 100
                product.suggested_qty = max(float_round(qty, precision_digits=0, rounding_method="UP"), 0)
        elif ctx.get("suggest_based_on"):
            for product in self:
                if product.monthly_demand <= 0:
                    continue
                monthly_ratio = ctx.get("suggest_days", 0) / (365.25 / 12)  # eg. 7 days / (365.25 days/yr / 12 mth/yr) = 0.23 months
                qty = product.monthly_demand * monthly_ratio * ctx.get("suggest_percent", 0) / 100
                qty -= max(product.qty_available, 0) + max(product.incoming_qty, 0)
                product.suggested_qty = max(float_round(qty, precision_digits=0, rounding_method="UP"), 0)

Back to entity