diff --git a/stock_available/__openerp__.py b/stock_available/__openerp__.py index 14dcb7397..f5748a838 100644 --- a/stock_available/__openerp__.py +++ b/stock_available/__openerp__.py @@ -4,7 +4,7 @@ { 'name': 'Stock available to promise', - 'version': '9.0.1.0.0', + 'version': '9.0.1.0.1', "author": "Numérigraphe, Sodexis, Odoo Community Association (OCA)", 'category': 'Warehouse', 'depends': ['stock'], diff --git a/stock_available/models/product_product.py b/stock_available/models/product_product.py index a22951f92..e76a67ee6 100644 --- a/stock_available/models/product_product.py +++ b/stock_available/models/product_product.py @@ -21,8 +21,11 @@ class ProductProduct(models.Model): By default, available to promise = forecasted quantity. - Must be overridden by another module that actually implement - computations.""" + **Each** sub-module **must** override this method in **both** + `product.product` **and** `product.template`, because we can't + decide in advance how to compute the template's quantity from the + variants. + """ for prod in self: prod.immediately_usable_qty = prod.virtual_available diff --git a/stock_available/models/product_template.py b/stock_available/models/product_template.py index a7f1fcc4b..96db9b15f 100644 --- a/stock_available/models/product_template.py +++ b/stock_available/models/product_template.py @@ -12,12 +12,17 @@ class ProductTemplate(models.Model): @api.multi @api.depends('product_variant_ids.immediately_usable_qty') def _immediately_usable_qty(self): - """Compute the quantity using all the variants""" + """No-op implementation of the stock available to promise. + + By default, available to promise = forecasted quantity. + + **Each** sub-module **must** override this method in **both** + `product.product` **and** `product.template`, because we can't + decide in advance how to compute the template's quantity from the + variants. + """ for tmpl in self: - tmpl.immediately_usable_qty = sum( - v.immediately_usable_qty - for v in tmpl.product_variant_ids - ) + tmpl.immediately_usable_qty = tmpl.virtual_available immediately_usable_qty = fields.Float( digits=dp.get_precision('Product Unit of Measure'),