From 047485dbbb8a6e6334e1418f1978e76be157f0d5 Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Sat, 6 Jul 2019 17:31:36 +0200 Subject: [PATCH] Make stock_available_mrp compatible with other modules like stock_available_immediately --- stock_available_mrp/models/__init__.py | 1 - stock_available_mrp/models/product_product.py | 1 + stock_available_mrp/models/product_template.py | 16 ---------------- stock_available_mrp/readme/CONTRIBUTORS.rst | 1 + 4 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 stock_available_mrp/models/product_template.py diff --git a/stock_available_mrp/models/__init__.py b/stock_available_mrp/models/__init__.py index 28a3f0d0a..bf91af2eb 100644 --- a/stock_available_mrp/models/__init__.py +++ b/stock_available_mrp/models/__init__.py @@ -2,4 +2,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import product_product -from . import product_template diff --git a/stock_available_mrp/models/product_product.py b/stock_available_mrp/models/product_product.py index 0cafb61e8..aa7111ca9 100644 --- a/stock_available_mrp/models/product_product.py +++ b/stock_available_mrp/models/product_product.py @@ -109,6 +109,7 @@ class ProductProduct(models.Model): bom_id = product.bom_id potential_qty = (bom_id.product_qty * components_potential_qty) + potential_qty = potential_qty > 0.0 and potential_qty or 0.0 # We want to respect the rounding factor of the potential_qty # Rounding down as we want to be pesimistic. diff --git a/stock_available_mrp/models/product_template.py b/stock_available_mrp/models/product_template.py deleted file mode 100644 index dee7e6147..000000000 --- a/stock_available_mrp/models/product_template.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2014 Numérigraphe SARL -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models, api - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - - @api.multi - def _compute_available_quantities_dict(self): - res = super(ProductTemplate, self)._compute_available_quantities_dict() - for template in self.filtered('bom_ids'): - res[template.id]['immediately_usable_qty'] =\ - template.virtual_available + res[template.id]['potential_qty'] - return res diff --git a/stock_available_mrp/readme/CONTRIBUTORS.rst b/stock_available_mrp/readme/CONTRIBUTORS.rst index e274f35bc..4f314834d 100644 --- a/stock_available_mrp/readme/CONTRIBUTORS.rst +++ b/stock_available_mrp/readme/CONTRIBUTORS.rst @@ -3,3 +3,4 @@ * many thanks to Graeme Gellatly for his advice and code review * Laurent Mignon * Cédric Pigeon +* Florian da Costa