diff --git a/stock_available_mrp/README.rst b/stock_available_mrp/README.rst index a308d3f0e..1fab2e59d 100644 --- a/stock_available_mrp/README.rst +++ b/stock_available_mrp/README.rst @@ -37,14 +37,24 @@ with the components available to promise. .. contents:: :local: +Usage +===== + +It's possible to avoid adding potential stock to available to promise stock at Bill of +Materials level. This is interesting in case that sum is missleading due to uncertain +manufacturing processes. To do so: + +- Go to that specific Bill of Materials and in the Miscellaneous tab set the option + **Avoid adding potential to available to promise** on. + Known issues / Roadmap ====================== Known issues ~~~~~~~~~~~~ -The manufacturing delays are not taken into account : this module assumes that +The manufacturing delays are not taken into account: this module assumes that if you have components in stock goods, you can manufacture finished goods -quickly enough. +quickly enough. This can be overriden at BoM level though. As a consequence, and to avoid overestimating, **only the first level** of Bill of Materials is considered. @@ -113,6 +123,7 @@ Contributors * `Tecnativa `_: * Víctor Martínez + * David Vidal Maintainers ~~~~~~~~~~~ diff --git a/stock_available_mrp/__manifest__.py b/stock_available_mrp/__manifest__.py index e474af25e..fe6188e3b 100644 --- a/stock_available_mrp/__manifest__.py +++ b/stock_available_mrp/__manifest__.py @@ -7,6 +7,7 @@ "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Hidden", "depends": ["stock_available", "mrp"], + "data": ["views/mrp_bom_views.xml"], "demo": ["demo/mrp_data.xml"], "license": "AGPL-3", "installable": True, diff --git a/stock_available_mrp/models/__init__.py b/stock_available_mrp/models/__init__.py index bf91af2eb..4612d56ea 100644 --- a/stock_available_mrp/models/__init__.py +++ b/stock_available_mrp/models/__init__.py @@ -1,4 +1,4 @@ # Copyright 2014 Numérigraphe SARL # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - +from . import mrp_bom from . import product_product diff --git a/stock_available_mrp/models/mrp_bom.py b/stock_available_mrp/models/mrp_bom.py new file mode 100644 index 000000000..619e1b1df --- /dev/null +++ b/stock_available_mrp/models/mrp_bom.py @@ -0,0 +1,13 @@ +# Copyright 2022 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class MrpBom(models.Model): + _inherit = "mrp.bom" + + add_potential_exception = fields.Boolean( + string="Avoid adding potential to available to promise", + help="If potential qty added to available to promise is set in the company " + "we can override this option for single BoMs", + ) diff --git a/stock_available_mrp/models/product_product.py b/stock_available_mrp/models/product_product.py index 1c9458c41..d49aea2d8 100644 --- a/stock_available_mrp/models/product_product.py +++ b/stock_available_mrp/models/product_product.py @@ -79,8 +79,19 @@ class ProductProduct(models.Model): ) res[product.id]["potential_qty"] = potential_qty - res[product.id]["immediately_usable_qty"] = potential_qty - + # Normal BoM products (those which are manufactured) are regular stored + # products and their immediately_usable_qty will be the sum of its regular + # available to promise quanity as storable product and its potential qty + # Phantom BoM products (kits) don't have real stock so their available + # to promise quantity will be the same as the potential. + if bom_id.type == "phantom": + res[product.id]["immediately_usable_qty"] = potential_qty + # We can override at BoM level to add the potential quantity to the + # manufactured product. This could be the case when the manufacturing + # proccess is uncertain and the promising such quantities could be + # missleading. + elif not bom_id.add_potential_exception: + res[product.id]["immediately_usable_qty"] += potential_qty return res, stock_dict def _explode_boms(self): diff --git a/stock_available_mrp/readme/CONTRIBUTORS.rst b/stock_available_mrp/readme/CONTRIBUTORS.rst index 1089a647b..50df76d7c 100644 --- a/stock_available_mrp/readme/CONTRIBUTORS.rst +++ b/stock_available_mrp/readme/CONTRIBUTORS.rst @@ -8,3 +8,4 @@ * `Tecnativa `_: * Víctor Martínez + * David Vidal diff --git a/stock_available_mrp/readme/ROADMAP.rst b/stock_available_mrp/readme/ROADMAP.rst index 88ebb1f2e..5d0b89e84 100644 --- a/stock_available_mrp/readme/ROADMAP.rst +++ b/stock_available_mrp/readme/ROADMAP.rst @@ -1,8 +1,8 @@ Known issues ~~~~~~~~~~~~ -The manufacturing delays are not taken into account : this module assumes that +The manufacturing delays are not taken into account: this module assumes that if you have components in stock goods, you can manufacture finished goods -quickly enough. +quickly enough. This can be overriden at BoM level though. As a consequence, and to avoid overestimating, **only the first level** of Bill of Materials is considered. diff --git a/stock_available_mrp/readme/USAGE.rst b/stock_available_mrp/readme/USAGE.rst new file mode 100644 index 000000000..841a63eb1 --- /dev/null +++ b/stock_available_mrp/readme/USAGE.rst @@ -0,0 +1,6 @@ +It's possible to avoid adding potential stock to available to promise stock at Bill of +Materials level. This is interesting in case that sum is missleading due to uncertain +manufacturing processes. To do so: + +- Go to that specific Bill of Materials and in the Miscellaneous tab set the option + **Avoid adding potential to available to promise** on. diff --git a/stock_available_mrp/static/description/index.html b/stock_available_mrp/static/description/index.html index 2ca48335e..5739bad41 100644 --- a/stock_available_mrp/static/description/index.html +++ b/stock_available_mrp/static/description/index.html @@ -3,7 +3,7 @@ - + Consider the production potential is available to promise