diff --git a/stock_available_mrp/README.rst b/stock_available_mrp/README.rst new file mode 100644 index 00000000..37c252d0 --- /dev/null +++ b/stock_available_mrp/README.rst @@ -0,0 +1,152 @@ +========================================================= +Consider the production potential is available to promise +========================================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:07930e0fab4e9b713917371909208d0384b7380575aea5f5116fac2a7a024595 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--availability-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-availability/tree/18.0/stock_available_mrp + :alt: OCA/stock-logistics-availability +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-availability-18-0/stock-logistics-availability-18-0-stock_available_mrp + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-availability&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module takes the potential quantities available for Products into +account in the quantity available to promise, where the "Potential +quantity" is the quantity that can be manufactured with the components +immediately at hand. By configuration, the "Potential quantity" can be +computed based on other product field. For example, "Potential quantity" +can be the quantity that can be manufactured with the components +available to promise. + +**Table of contents** + +.. contents:: + :local: + +Known issues / Roadmap +====================== + +Known issues +------------ + +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. + +As a consequence, and to avoid overestimating, **only the first level** +of Bill of Materials is considered. + +However Sets (a.k.a "phantom" BoMs) are taken into account: if a +component must be replaced with a set, it's the stock of the set's +product which will decide the potential. + +If a product has several variants, only the variant with the biggest +potential will be taken into account when reporting the production +potential. For example, even if you actually have enough components to +make 10 iPads 16Go AND 42 iPads 32Go, we'll consider that you can +promise only 42 iPads. + +Removed features +---------------- + +Previous versions of this module used to let programmers demand to get +the potential quantity in an arbitrary Unit of Measure using the +context. This feature was present in the standard computations too until +v8.0, but it has been dropped from the standard from v8.0 on. + +For the sake of consistency the potential quantity is now always +reported in the product's main Unit of Measure too. + +Roadmap +------- + +Possible improvements for future versions: + +- Take manufacturing delays into account: we should not promise goods + to customers if they want them delivered earlier that we can make + them +- Compute the quantity of finished product that can be made directly on + each Bill of Material: this would be useful for production managers, + and may make the computations faster by avoiding to compute the same + BoM several times when several variants share the same BoM. +- Add an option (probably as a sub-module) to consider all raw + materials as available if they can be bought from the suppliers in + time for the manufacturing. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Numérigraphe + +Contributors +------------ + +- Loïc Bellier (Numérigraphe) + +- Lionel Sausin (Numérigraphe) + +- many thanks to Graeme Gellatly for his advice and code review + +- Laurent Mignon + +- Cédric Pigeon + +- Florian da Costa + +- Joan Mateu + +- `Tecnativa `__: + + - Víctor Martínez + +- `Trobz `__: + + - Khoi Vo + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/stock-logistics-availability `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_available_mrp/__init__.py b/stock_available_mrp/__init__.py new file mode 100644 index 00000000..2f72d6f9 --- /dev/null +++ b/stock_available_mrp/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2014 Numérigraphe SARL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/stock_available_mrp/__manifest__.py b/stock_available_mrp/__manifest__.py new file mode 100644 index 00000000..f4e611dd --- /dev/null +++ b/stock_available_mrp/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2014 Numérigraphe SARL, Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Consider the production potential is available to promise", + "version": "18.0.1.0.0", + "author": "Numérigraphe," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-availability", + "category": "Hidden", + "depends": ["stock_available", "mrp"], + "demo": ["demo/mrp_data.xml"], + "data": [ + "views/res_config_settings_views.xml", + ], + "license": "AGPL-3", + "installable": True, +} diff --git a/stock_available_mrp/demo/mrp_data.xml b/stock_available_mrp/demo/mrp_data.xml new file mode 100644 index 00000000..7ce98dde --- /dev/null +++ b/stock_available_mrp/demo/mrp_data.xml @@ -0,0 +1,48 @@ + + + + PCSC234-WHITE + + + + + + + + + + + Bolt + + 1.0 + 5.0 + consu + + + + BOLT-WHITE + + + + 4 + + 5 + + + + diff --git a/stock_available_mrp/i18n/ca.po b/stock_available_mrp/i18n/ca.po new file mode 100644 index 00000000..11a058dc --- /dev/null +++ b/stock_available_mrp/i18n/ca.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-08-17 12:07+0000\n" +"Last-Translator: jabelchi \n" +"Language-Team: none\n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.3.2\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "Cargol" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Producte" + +#~ msgid "Table Kit" +#~ msgstr "Kit de taula" + +#~ msgid "Table kit" +#~ msgstr "Kit de taula" + +#~ msgid "Units" +#~ msgstr "Unitats" diff --git a/stock_available_mrp/i18n/de.po b/stock_available_mrp/i18n/de.po new file mode 100644 index 00000000..356c9511 --- /dev/null +++ b/stock_available_mrp/i18n/de.po @@ -0,0 +1,62 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +# Rudolf Schnapka , 2016 +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-14 01:38+0000\n" +"PO-Revision-Date: 2016-01-14 09:35+0000\n" +"Last-Translator: Rudolf Schnapka \n" +"Language-Team: German (http://www.transifex.com/oca/OCA-stock-logistics-" +"warehouse-8-0/language/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Produkt" + +#~ msgid "Product Template" +#~ msgstr "Produktvorlage" + +#~ msgid "Thousand" +#~ msgstr "Tausend" diff --git a/stock_available_mrp/i18n/es.po b/stock_available_mrp/i18n/es.po new file mode 100644 index 00000000..19e4e44d --- /dev/null +++ b/stock_available_mrp/i18n/es.po @@ -0,0 +1,83 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-14 01:38+0000\n" +"PO-Revision-Date: 2023-10-15 20:37+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (http://www.transifex.com/oca/OCA-stock-logistics-" +"warehouse-8-0/language/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "Perno" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "Variante del Producto" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Display Name" +#~ msgstr "Mostrar Nombre" + +#~ msgid "ID" +#~ msgstr "ID (identificación)" + +#~ msgid "Last Modified on" +#~ msgstr "Última Modificación el" + +#~ msgid "Product" +#~ msgstr "Producto" + +#~ msgid "Table Kit" +#~ msgstr "Conjunto de mesa" + +#~ msgid "Table kit" +#~ msgstr "Conjunto de mesa" + +#~ msgid "Units" +#~ msgstr "Unidades" + +#~ msgid "kg" +#~ msgstr "kilogramos" + +#~ msgid "m³" +#~ msgstr "metros cúbicos" + +#~ msgid "Product Template" +#~ msgstr "Plantilla de producto" diff --git a/stock_available_mrp/i18n/fi.po b/stock_available_mrp/i18n/fi.po new file mode 100644 index 00000000..5589c399 --- /dev/null +++ b/stock_available_mrp/i18n/fi.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-14 01:38+0000\n" +"PO-Revision-Date: 2016-01-13 16:35+0000\n" +"Last-Translator: <>\n" +"Language-Team: Finnish (http://www.transifex.com/oca/OCA-stock-logistics-" +"warehouse-8-0/language/fi/)\n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Tuote" + +#~ msgid "Product Template" +#~ msgstr "Tuotteen malli" diff --git a/stock_available_mrp/i18n/fr.po b/stock_available_mrp/i18n/fr.po new file mode 100644 index 00000000..fcd4e09f --- /dev/null +++ b/stock_available_mrp/i18n/fr.po @@ -0,0 +1,74 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-14 01:38+0000\n" +"PO-Revision-Date: 2020-11-12 12:44+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: French (http://www.transifex.com/oca/OCA-stock-logistics-" +"warehouse-8-0/language/fr/)\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "Boulon" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Article" + +#~ msgid "Table Kit" +#~ msgstr "Table en kit" + +#~ msgid "Table kit" +#~ msgstr "Table en kit" + +#~ msgid "kg" +#~ msgstr "kg" + +#~ msgid "BOM" +#~ msgstr "Nomenclature" + +#~ msgid "Unit(s)" +#~ msgstr "Unité(s)" + +#~ msgid "Product Template" +#~ msgstr "Modèle de produit" diff --git a/stock_available_mrp/i18n/hr_HR.po b/stock_available_mrp/i18n/hr_HR.po new file mode 100644 index 00000000..5387abbc --- /dev/null +++ b/stock_available_mrp/i18n/hr_HR.po @@ -0,0 +1,89 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +# Bole , 2016 +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (9.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-06-12 19:59+0000\n" +"PO-Revision-Date: 2016-06-14 10:45+0000\n" +"Last-Translator: Bole \n" +"Language-Team: Croatian (Croatia) (http://www.transifex.com/oca/OCA-stock-" +"logistics-warehouse-9-0/language/hr_HR/)\n" +"Language: hr_HR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Proizvod" + +#~ msgid "Product Template" +#~ msgstr "Predložak proizvoda" + +#~ msgid "Potential" +#~ msgstr "Potencijal" + +#~ msgid "Component ids" +#~ msgstr "ID-ovi komponenata" + +#~ msgid "Potential" +#~ msgstr "Potencijal" + +#~ msgid "" +#~ "Quantity of this Product that could be produced using the materials " +#~ "already at hand." +#~ msgstr "" +#~ "Količina ovog proizvoda nije mogla biti proizvedena korištenjem trenutno " +#~ "raspoloživih materijala." + +#~ msgid "" +#~ "Quantity of this Product that could be produced using the materials " +#~ "already at hand. If the product has several variants, this will be the " +#~ "biggest quantity that can be made for a any single variant." +#~ msgstr "" +#~ "Količina ovog proizvoda koja može biti proizvodedna raspoloživim " +#~ "količinama sirovina. Ako proizvod ima nekoliko varijanti, ovo će biti " +#~ "najveća moguća količina koja se može proizvesti za svaku pojedinu " +#~ "varijantu." + +#~ msgid "Thousand" +#~ msgstr "Tisuću" diff --git a/stock_available_mrp/i18n/it.po b/stock_available_mrp/i18n/it.po new file mode 100644 index 00000000..ca138d68 --- /dev/null +++ b/stock_available_mrp/i18n/it.po @@ -0,0 +1,60 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (9.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-09-04 10:11+0000\n" +"PO-Revision-Date: 2025-01-21 12:06+0000\n" +"Last-Translator: mymage \n" +"Language-Team: Italian (http://www.transifex.com/oca/" +"OCA-stock-logistics-warehouse-9-0/language/it/)\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.6.2\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "Bullone" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" +"Scegliere il campo del prodotto che verrà utilizzato per calcolare il " +"potenziale.\n" +"Se vuoto, verrà usato Quantità disponibile.\n" +"Solo i campi quantità hanno senso per calcolare la giacenza" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "Impostazioni configurazione" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "Variante prodotto" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "Giagenza disponibile alla promessa" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "basato su" + +#~ msgid "Product" +#~ msgstr "Prodotto" diff --git a/stock_available_mrp/i18n/pt_BR.po b/stock_available_mrp/i18n/pt_BR.po new file mode 100644 index 00000000..87ccc5b4 --- /dev/null +++ b/stock_available_mrp/i18n/pt_BR.po @@ -0,0 +1,87 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +# Claudio Araujo Santos , 2016 +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (9.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-07-03 20:56+0000\n" +"PO-Revision-Date: 2016-07-07 19:41+0000\n" +"Last-Translator: Claudio Araujo Santos \n" +"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-stock-" +"logistics-warehouse-9-0/language/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Produto" + +#~ msgid "Product Template" +#~ msgstr "Modelo Produto" + +#~ msgid "Potential" +#~ msgstr "Potencial" + +#~ msgid "Component ids" +#~ msgstr "IDs de componentes" + +#~ msgid "Potential" +#~ msgstr "Potencial" + +#~ msgid "" +#~ "Quantity of this Product that could be produced using the materials " +#~ "already at hand." +#~ msgstr "" +#~ "Quantidade deste produto que poderia ser produzido usando os materiais já " +#~ "na mão." + +#~ msgid "" +#~ "Quantity of this Product that could be produced using the materials " +#~ "already at hand. If the product has several variants, this will be the " +#~ "biggest quantity that can be made for a any single variant." +#~ msgstr "" +#~ "Quantidade deste produto que poderia ser produzido usando os materiais já " +#~ "na mão. Se o produto tiver várias variantes, esta será a maior quantidade " +#~ "que pode ser feito por qualquer uma única variante." + +#~ msgid "Thousand" +#~ msgstr "Mil" diff --git a/stock_available_mrp/i18n/sl.po b/stock_available_mrp/i18n/sl.po new file mode 100644 index 00000000..52e2f9db --- /dev/null +++ b/stock_available_mrp/i18n/sl.po @@ -0,0 +1,63 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +# Matjaž Mozetič , 2016 +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (8.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-01-14 01:38+0000\n" +"PO-Revision-Date: 2016-01-14 05:18+0000\n" +"Last-Translator: Matjaž Mozetič \n" +"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-stock-logistics-" +"warehouse-8-0/language/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3);\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "Proizvod" + +#~ msgid "Product Template" +#~ msgstr "Predloga proizvoda" + +#~ msgid "Thousand" +#~ msgstr "Tisoč" diff --git a/stock_available_mrp/i18n/stock_available_mrp.pot b/stock_available_mrp/i18n/stock_available_mrp.pot new file mode 100644 index 00000000..f4b74d50 --- /dev/null +++ b/stock_available_mrp/i18n/stock_available_mrp.pot @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" diff --git a/stock_available_mrp/i18n/zh_CN.po b/stock_available_mrp/i18n/zh_CN.po new file mode 100644 index 00000000..14495db7 --- /dev/null +++ b/stock_available_mrp/i18n/zh_CN.po @@ -0,0 +1,84 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +# Translators: +# Jeffery Chenn , 2016 +msgid "" +msgstr "" +"Project-Id-Version: stock-logistics-warehouse (9.0)\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-28 10:00+0000\n" +"PO-Revision-Date: 2019-09-26 15:05+0000\n" +"Last-Translator: 黎伟杰 <674416404@qq.com>\n" +"Language-Team: Chinese (China) (http://www.transifex.com/oca/OCA-stock-" +"logistics-warehouse-9-0/language/zh_CN/)\n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Weblate 3.8\n" + +#. module: stock_available_mrp +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "螺栓" + +#. module: stock_available_mrp +#: model:ir.model.fields,help:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "" +"Choose the field of the product which will be used to compute potential.\n" +"If empty, Quantity On Hand is used.\n" +"Only the quantity fields have meaning for computing stock" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_res_config_settings +msgid "Config Settings" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: stock_available_mrp +#: model_terms:ir.ui.view,arch_db:stock_available_mrp.view_stock_configuration +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_res_config_settings__stock_available_mrp_based_on +msgid "based on" +msgstr "" + +#~ msgid "Product" +#~ msgstr "产品" + +#~ msgid "Table Kit" +#~ msgstr "桌台套件" + +#~ msgid "Table kit" +#~ msgstr "桌台套件" + +#~ msgid "kg" +#~ msgstr "公斤" + +#~ msgid "BOM" +#~ msgstr "BOM" + +#~ msgid "Unit(s)" +#~ msgstr "件" + +#~ msgid "Product Template" +#~ msgstr "产品模板" + +#~ msgid "Potential" +#~ msgstr "潜在" + +#~ msgid "Potential" +#~ msgstr "潜在" + +#~ msgid "Thousand" +#~ msgstr "千" diff --git a/stock_available_mrp/migrations/18.0.1.0.0/post-migration.py b/stock_available_mrp/migrations/18.0.1.0.0/post-migration.py new file mode 100644 index 00000000..57562fb4 --- /dev/null +++ b/stock_available_mrp/migrations/18.0.1.0.0/post-migration.py @@ -0,0 +1,17 @@ +from odoo import SUPERUSER_ID, api + + +def migrate(cr, version): + """Migrate value from old parameter key to new parameter key. + + New parameter key was introduced in 17.0 in res.config.parameter but not + actually used. + """ + new_key = "stock_available_mrp.stock_available_mrp_based_on" + old_key = "stock_available_mrp_based_on" + env = api.Environment(cr, SUPERUSER_ID, {}) + value = env["ir.config_parameter"].get_param(old_key, None) + if value: + env["ir.config_parameter"].set_param(new_key, value) + # Clean up old key to avoid any future confusion + env["ir.config_parameter"].search([("key", "=", old_key)]).unlink() diff --git a/stock_available_mrp/models/__init__.py b/stock_available_mrp/models/__init__.py new file mode 100644 index 00000000..8d2c6491 --- /dev/null +++ b/stock_available_mrp/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2014 Numérigraphe SARL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import product_product +from . import res_config_settings diff --git a/stock_available_mrp/models/product_product.py b/stock_available_mrp/models/product_product.py new file mode 100644 index 00000000..37c18a07 --- /dev/null +++ b/stock_available_mrp/models/product_product.py @@ -0,0 +1,188 @@ +# Copyright 2014 Numérigraphe SARL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from collections import Counter + +from odoo import api, models +from odoo.fields import first +from odoo.tools import float_round + + +class ProductProduct(models.Model): + _inherit = "product.product" + + @api.depends( + "virtual_available", + "bom_ids", + "bom_ids.product_qty", + "variant_bom_ids", + "variant_bom_ids.product_qty", + ) + def _compute_available_quantities(self): + res = super()._compute_available_quantities() + return res + + def _compute_available_quantities_dict(self): + res, stock_dict = super()._compute_available_quantities_dict() + # compute qty for product with bom + product_with_bom = self.filtered("variant_bom_ids") + product_with_bom |= (self - product_with_bom).filtered( + lambda p: p.bom_ids + and any(not bom.product_id or bom.product_id == p for bom in p.bom_ids) + ) + + if not product_with_bom: + return res, stock_dict + icp = self.env["ir.config_parameter"] + stock_available_mrp_based_on = icp.sudo().get_param( + "stock_available_mrp.stock_available_mrp_based_on", + "qty_available", + ) + + # explode all boms at once + exploded_boms = product_with_bom._explode_boms() + + # extract the list of product used as bom component + component_products = self.env["product.product"].browse() + for exploded_components in exploded_boms.values(): + for bom_component in exploded_components: + component_products |= first(bom_component).product_id + + # Compute stock for product components. + # {'productid': {field_name: qty}} + if stock_dict and stock_available_mrp_based_on in list(stock_dict.values())[0]: + # If the qty is computed by the same method use it to avoid + # stressing the cache + _, component_qties = component_products._compute_available_quantities_dict() + else: + # The qty is a field computed by an other method than the + # current one. Take the value on the record. + component_qties = { + p.id: {stock_available_mrp_based_on: p[stock_available_mrp_based_on]} + for p in component_products + } + + for product in product_with_bom: + # Need by product (same product can be in many BOM lines/levels) + bom_id = first( + product.variant_bom_ids + or product.bom_ids.filtered( + lambda b, product=product: not b.product_id + or b.product_id == product + ) + ) + exploded_components = exploded_boms[product.id] + component_needs = product._get_components_needs(exploded_components) + if not component_needs: + # The BoM has no line we can use + potential_qty = 0.0 + else: + # Find the lowest quantity we can make with the stock at hand + components_potential_qty = min( + component_qties[component.id][stock_available_mrp_based_on] / need + for component, need in component_needs.items() + ) + 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. + potential_qty = bom_id.product_uom_id._compute_quantity( + potential_qty, + bom_id.product_tmpl_id.uom_id, + rounding_method="DOWN", + ) + + res[product.id]["potential_qty"] = potential_qty + res[product.id]["immediately_usable_qty"] += potential_qty + + return res, stock_dict + + def _explode_boms(self): + """ + return a dict by product_id of exploded bom lines + :return: + """ + return self.explode_bom_quantities() + + @api.model + def _get_components_needs(self, exploded_components): + """Return the needed qty of each compoments in the exploded_components + + :type exploded_components + :rtype: collections.Counter + """ + needs = Counter() + for bom_line, bom_qty in exploded_components: + component = bom_line.product_id + needs += Counter({component: bom_qty}) + + return needs + + def explode_bom_quantities(self): + """Explode a bill of material with quantities to consume + + It returns a dict with the exploded bom lines and + the quantity they consume. Example:: + + { + : [ + (, ) + (, ) + ] + } + + The 'MrpBom.explode()' method includes the same information, with other + things, but is under-optimized to be used for the purpose of this + module. The killer is particularly the call to `_bom_find()` which can + generate thousands of SELECT for searches. + """ + result = {} + + for product in self: + lines_done = [] + bom_lines = [ + (first(product.bom_ids), bom_line, product, 1.0) + for bom_line in first(product.bom_ids).bom_line_ids + ] + + while bom_lines: + (current_bom, current_line, current_product, current_qty) = bom_lines[0] + bom_lines = bom_lines[1:] + + if current_line._skip_bom_line(current_product): + continue + + line_quantity = current_qty * current_line.product_qty + + sub_bom = first(current_line.product_id.bom_ids) + if sub_bom.type == "phantom": + product_uom = current_line.product_uom_id + converted_line_quantity = product_uom._compute_quantity( + line_quantity / sub_bom.product_qty, + sub_bom.product_uom_id, + ) + bom_lines = [ + ( + sub_bom, + line, + current_line.product_id, + converted_line_quantity, + ) + for line in sub_bom.bom_line_ids + ] + bom_lines + else: + # We round up here because the user expects that if he has + # to consume a little more, the whole UOM unit should be + # consumed. + rounding = current_line.product_uom_id.rounding + line_quantity = float_round( + line_quantity, + precision_rounding=rounding, + rounding_method="UP", + ) + lines_done.append((current_line, line_quantity)) + + result[product.id] = lines_done + + return result diff --git a/stock_available_mrp/models/res_config_settings.py b/stock_available_mrp/models/res_config_settings.py new file mode 100644 index 00000000..e7bdcebf --- /dev/null +++ b/stock_available_mrp/models/res_config_settings.py @@ -0,0 +1,25 @@ +from odoo import api, fields, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + @api.model + def _get_stock_available_mrp_based_on(self): + """Gets the available languages for the selection.""" + pdct_fields = self.env["ir.model.fields"].search( + [("model", "=", "product.product"), ("ttype", "=", "float")] + ) + return [ + (field.name, field.field_description) + for field in sorted(pdct_fields, key=lambda f: f.field_description) + ] + + stock_available_mrp_based_on = fields.Selection( + _get_stock_available_mrp_based_on, + string="Availability of BoM products is based on", + config_parameter="stock_available_mrp.stock_available_mrp_based_on", + help="Choose the field of the product which will be used to compute " + "potential.\nIf empty, Quantity On Hand is used.\n" + "Only the quantity fields have meaning for computing stock", + ) diff --git a/stock_available_mrp/pyproject.toml b/stock_available_mrp/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/stock_available_mrp/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/stock_available_mrp/readme/CONTRIBUTORS.md b/stock_available_mrp/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..be9b9426 --- /dev/null +++ b/stock_available_mrp/readme/CONTRIBUTORS.md @@ -0,0 +1,21 @@ +- Loïc Bellier (Numérigraphe) \<\> + +- Lionel Sausin (Numérigraphe) \<\> + +- many thanks to Graeme Gellatly for his advice and code review + +- Laurent Mignon \<\> + +- Cédric Pigeon \<\> + +- Florian da Costa \<\> + +- Joan Mateu \<\> + +- [Tecnativa](https://www.tecnativa.com): + + - Víctor Martínez + +- [Trobz](https://trobz.com): + + > - Khoi Vo \<\> diff --git a/stock_available_mrp/readme/DESCRIPTION.md b/stock_available_mrp/readme/DESCRIPTION.md new file mode 100644 index 00000000..b67180a9 --- /dev/null +++ b/stock_available_mrp/readme/DESCRIPTION.md @@ -0,0 +1,7 @@ +This module takes the potential quantities available for Products into +account in the quantity available to promise, where the "Potential +quantity" is the quantity that can be manufactured with the components +immediately at hand. By configuration, the "Potential quantity" can be +computed based on other product field. For example, "Potential quantity" +can be the quantity that can be manufactured with the components +available to promise. diff --git a/stock_available_mrp/readme/ROADMAP.md b/stock_available_mrp/readme/ROADMAP.md new file mode 100644 index 00000000..5f07b347 --- /dev/null +++ b/stock_available_mrp/readme/ROADMAP.md @@ -0,0 +1,42 @@ +## Known issues + +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. + +As a consequence, and to avoid overestimating, **only the first level** +of Bill of Materials is considered. + +However Sets (a.k.a "phantom" BoMs) are taken into account: if a +component must be replaced with a set, it's the stock of the set's +product which will decide the potential. + +If a product has several variants, only the variant with the biggest +potential will be taken into account when reporting the production +potential. For example, even if you actually have enough components to +make 10 iPads 16Go AND 42 iPads 32Go, we'll consider that you can +promise only 42 iPads. + +## Removed features + +Previous versions of this module used to let programmers demand to get +the potential quantity in an arbitrary Unit of Measure using the +context. This feature was present in the standard computations too until +v8.0, but it has been dropped from the standard from v8.0 on. + +For the sake of consistency the potential quantity is now always +reported in the product's main Unit of Measure too. + +## Roadmap + +Possible improvements for future versions: + +- Take manufacturing delays into account: we should not promise goods to + customers if they want them delivered earlier that we can make them +- Compute the quantity of finished product that can be made directly on + each Bill of Material: this would be useful for production managers, + and may make the computations faster by avoiding to compute the same + BoM several times when several variants share the same BoM. +- Add an option (probably as a sub-module) to consider all raw materials + as available if they can be bought from the suppliers in time for the + manufacturing. diff --git a/stock_available_mrp/static/description/icon.png b/stock_available_mrp/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/stock_available_mrp/static/description/icon.png differ diff --git a/stock_available_mrp/static/description/index.html b/stock_available_mrp/static/description/index.html new file mode 100644 index 00000000..5cb207b5 --- /dev/null +++ b/stock_available_mrp/static/description/index.html @@ -0,0 +1,504 @@ + + + + + +Consider the production potential is available to promise + + + +
+

Consider the production potential is available to promise

+ + +

Beta License: AGPL-3 OCA/stock-logistics-availability Translate me on Weblate Try me on Runboat

+

This module takes the potential quantities available for Products into +account in the quantity available to promise, where the “Potential +quantity” is the quantity that can be manufactured with the components +immediately at hand. By configuration, the “Potential quantity” can be +computed based on other product field. For example, “Potential quantity” +can be the quantity that can be manufactured with the components +available to promise.

+

Table of contents

+ +
+

Known issues / Roadmap

+
+

Known issues

+

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.

+

As a consequence, and to avoid overestimating, only the first level +of Bill of Materials is considered.

+

However Sets (a.k.a “phantom” BoMs) are taken into account: if a +component must be replaced with a set, it’s the stock of the set’s +product which will decide the potential.

+

If a product has several variants, only the variant with the biggest +potential will be taken into account when reporting the production +potential. For example, even if you actually have enough components to +make 10 iPads 16Go AND 42 iPads 32Go, we’ll consider that you can +promise only 42 iPads.

+
+
+

Removed features

+

Previous versions of this module used to let programmers demand to get +the potential quantity in an arbitrary Unit of Measure using the +context. This feature was present in the standard computations too until +v8.0, but it has been dropped from the standard from v8.0 on.

+

For the sake of consistency the potential quantity is now always +reported in the product’s main Unit of Measure too.

+
+
+

Roadmap

+

Possible improvements for future versions:

+
    +
  • Take manufacturing delays into account: we should not promise goods +to customers if they want them delivered earlier that we can make +them
  • +
  • Compute the quantity of finished product that can be made directly on +each Bill of Material: this would be useful for production managers, +and may make the computations faster by avoiding to compute the same +BoM several times when several variants share the same BoM.
  • +
  • Add an option (probably as a sub-module) to consider all raw +materials as available if they can be bought from the suppliers in +time for the manufacturing.
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Numérigraphe
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/stock-logistics-availability project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/stock_available_mrp/tests/__init__.py b/stock_available_mrp/tests/__init__.py new file mode 100644 index 00000000..713631fc --- /dev/null +++ b/stock_available_mrp/tests/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2014 Numérigraphe SARL +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_potential_qty +from . import test_migration diff --git a/stock_available_mrp/tests/test_migration.py b/stock_available_mrp/tests/test_migration.py new file mode 100644 index 00000000..0f552e13 --- /dev/null +++ b/stock_available_mrp/tests/test_migration.py @@ -0,0 +1,48 @@ +import os + +from odoo.modules.migration import load_script +from odoo.tests.common import TransactionCase + + +class TestMigrations(TransactionCase): + def get_migration_module(self, module, version, script="post-migration.py"): + """Get the migration module. + + :param module: the addon that hosts the migration script. + :param version: the /migrations/ subdirectory containing + the migration script. + :param script: the filename of the migration script. + """ + pyfile = os.path.join(module, "migrations", version, script) + name, ext = os.path.splitext(os.path.basename(pyfile)) + return load_script(pyfile, name) + + def run_migration(self, module, version, script="post-migration.py"): + """Run a migration script. + + :param module: the addon that hosts the migration script. + :param version: the /migrations/ subdirectory containing + the migration script. + :param script: the filename of the migration script. + """ + mod = self.get_migration_module(module, version, script=script) + mod.migrate(self.env.cr, version) + self.env.invalidate_all() + + def test_config_parameter(self): + """In 17.0, the configuration option was actually unused.""" + new_key = "stock_available_mrp.stock_available_mrp_based_on" + old_key = "stock_available_mrp_based_on" + # Let's say that in 17.0, someone once configured 'virtual_available' + # as the field to base mrp potential on. + self.env["ir.config_parameter"].set_param(new_key, "virtual_available") + # But in the code, a different parameter was used. For this parameter, + # a default was set using xml data. + self.env["ir.config_parameter"].set_param(old_key, "qty_available") + # We don't want anything to change after the migration, so we copy + # the field name that was actually used to determine the computation + # to the configuration parameter that is going to be used in 18.0. + self.run_migration("stock_available_mrp", "18.0.1.0.0", "post-migration.py") + self.assertEqual( + self.env["ir.config_parameter"].get_param(new_key), "qty_available" + ) diff --git a/stock_available_mrp/tests/test_potential_qty.py b/stock_available_mrp/tests/test_potential_qty.py new file mode 100644 index 00000000..339496fa --- /dev/null +++ b/stock_available_mrp/tests/test_potential_qty.py @@ -0,0 +1,518 @@ +# Copyright 2014 Numérigraphe SARL +# Copyright 2021 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from unittest.mock import Mock + +from odoo.fields import Command +from odoo.osv.expression import TRUE_LEAF +from odoo.tests.common import TransactionCase + + +class TestPotentialQty(TransactionCase): + """Test the potential quantity on a product with a multi-line BoM""" + + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.product_model = cls.env["product.product"] + cls.bom_model = cls.env["mrp.bom"] + cls.bom_line_model = cls.env["mrp.bom.line"] + cls.stock_quant_model = cls.env["stock.quant"] + cls.config = cls.env["ir.config_parameter"] + cls.location = cls.env["stock.location"] + cls.main_company = cls.env.ref("base.main_company") + # Get the warehouses + cls.wh_main = cls.env.ref("stock.warehouse0") + + cls.company2 = cls.env["res.company"].create( + {"name": __name__, "parent_id": cls.main_company.id} + ) + cls.wh_ch = cls.env["stock.warehouse"].search( + [("company_id", "=", cls.company2.id)] + ) + + # We need to compute parent_left and parent_right of the locations as + # they are used to compute qty_available of the product. + cls.location._parent_store_compute() + cls.env["ir.config_parameter"].set_param( + "stock_available_mrp.stock_available_mrp_based_on", + "qty_available", + ) + cls.setup_demo_data() + + @classmethod + def setup_demo_data(cls): + #  An interesting product (multi-line BoM, variants) + cls.tmpl = cls.env.ref("mrp.product_product_table_kit_product_template") + #  First variant + cls.var1 = cls.env.ref("mrp.product_product_table_kit") + cls.var1.type = "consu" + cls.var1.is_storable = True + #  Second variant + cls.var2 = cls.env.ref("stock_available_mrp.product_kit_1a") + cls.var2.type = "consu" + cls.var2.is_storable = True + # Make bolt a stockable product to be able to change its stock + # we need to unreserve the existing move before being able to do it. + bolt = cls.env.ref("mrp.product_product_computer_desk_bolt") + bolt.stock_move_ids._do_unreserve() + bolt.type = "consu" + bolt.is_storable = True + # Components that can be used to make the product + components = [ + # Bolt + bolt, + # Wood Panel + cls.env.ref("mrp.product_product_wood_panel"), + ] + # Zero-out the inventory of all variants and components + for component in components + [v for v in cls.tmpl.product_variant_ids]: + moves = component.stock_move_ids.filtered( + lambda mo: mo.state not in ("done", "cancel") + ) + moves._action_cancel() + + component.stock_quant_ids.unlink() + + # A product without a BoM + cls.product_wo_bom = cls.env.ref("product.product_product_11") + + def create_inventory(self, product, qty, location=None, company=None): + if location is None: + location = self.wh_main.lot_stock_id + quant = self.env["stock.quant"] + if company: + quant = quant.with_company(company) + quant._update_available_quantity(product, location, qty) + + def assertPotentialQty(self, record, qty, msg): + record.invalidate_model() + # Check the potential + self.assertEqual(record.potential_qty, qty, msg) + + def test_00_res_config(self): + """Test the config file""" + stock_setting = self.env["res.config.settings"].create({}) + stock_setting.stock_available_mrp_based_on = "qty_available" + self.assertEqual(stock_setting.stock_available_mrp_based_on, "qty_available") + stock_setting.stock_available_mrp_based_on = "immediately_usable_qty" + stock_setting.set_values() + self.assertEqual( + stock_setting.stock_available_mrp_based_on, "immediately_usable_qty" + ) + self.assertEqual( + self.env["ir.config_parameter"].get_param( + "stock_available_mrp.stock_available_mrp_based_on" + ), + "immediately_usable_qty", + ) + + def test_01_potential_qty_no_bom(self): + #  Check the potential when there's no BoM + self.assertPotentialQty( + self.product_wo_bom, 0.0, "The potential without a BoM should be 0" + ) + + def test_02_potential_qty_no_bom_for_company(self): + # Receive 1000x Wood Panel owned by Company2 + self.create_inventory( + product=self.env.ref("mrp.product_product_wood_panel"), + qty=1000.0, + location=self.wh_ch.lot_stock_id, + company=self.company2, + ) + # Put Bolt owned by Company2 for 1000x the 1st variant in main WH + self.create_inventory( + product=self.env.ref("mrp.product_product_computer_desk_bolt"), + qty=1000.0, + location=self.wh_ch.lot_stock_id, + company=self.company2, + ) + self.assertPotentialQty( + self.tmpl, 250.0, "Wrong template potential after receiving components" + ) + + test_user = self.env["res.users"].create( + { + "name": "test_demo", + "login": "test_demo", + "company_id": self.main_company.id, + "company_ids": [ + Command.link(self.main_company.id), + Command.link(self.company2.id), + ], + "groups_id": [ + Command.link(self.ref("stock.group_stock_user")), + Command.link(self.ref("mrp.group_mrp_user")), + ], + } + ) + + test_user_tmpl = self.tmpl.with_user(test_user) + self.assertPotentialQty( + test_user_tmpl, 250.0, "Simple user can access to the potential_qty" + ) + + # Set the bom on the main company (visible to members of main company) + # and all products without company (visible to all) + # and the demo user on Company2 (child of main company) + bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.tmpl.id)]) + self.env["product.product"].search([TRUE_LEAF]).write({"company_id": False}) + test_user.write({"company_ids": [Command.set(self.main_company.ids)]}) + bom.company_id = self.main_company + self.assertPotentialQty( + test_user_tmpl, + 0, + "The bom should not be visible to non members of the bom's " + "company or company child of the bom's company", + ) + bom.company_id = self.company2 + test_user.write({"company_ids": [Command.link(self.company2.id)]}) + self.assertPotentialQty(test_user_tmpl, 250.0, "") + + def test_03_potential_qty(self): + for i in [self.tmpl, self.var1, self.var2]: + self.assertPotentialQty(i, 0.0, "The potential quantity should start at 0") + + # Receive 1000x Wood Panel + self.create_inventory( + product=self.env.ref("mrp.product_product_wood_panel"), + qty=1000.0, + location=self.wh_main.lot_stock_id, + ) + for i in [self.tmpl, self.var1, self.var2]: + self.assertPotentialQty( + i, + 0.0, + "Receiving a single component should not change the " + f"potential of {i}", + ) + + # Receive enough bolt to make 1000x the 1st variant in main WH + self.create_inventory( + product=self.env.ref("mrp.product_product_computer_desk_bolt"), + qty=1000.0, + location=self.wh_main.lot_stock_id, + ) + self.assertPotentialQty( + self.tmpl, 250.0, "Wrong template potential after receiving components" + ) + self.assertPotentialQty( + self.var1, 250.0, "Wrong variant 1 potential after receiving components" + ) + self.assertPotentialQty( + self.var2, + 0.0, + "Receiving variant 1's component should not change " + "variant 2's potential", + ) + + # Receive enough components to make 213 the 2nd variant at Company2 + self.create_inventory( + self.env.ref("mrp.product_product_wood_panel"), + 1000.0, + self.wh_ch.lot_stock_id, + self.company2, + ) + self.create_inventory( + self.env.ref("stock_available_mrp.product_computer_desk_bolt_white"), + 852.0, + self.wh_ch.lot_stock_id, + self.company2, + ) + self.assertPotentialQty( + self.tmpl.with_context(test=True), + 250.0, + "Wrong template potential after receiving components", + ) + self.assertPotentialQty( + self.var1, + 250.0, + "Receiving variant 2's component should not change " + "variant 1's potential", + ) + self.assertPotentialQty( + self.var2, 213.0, "Wrong variant 2 potential after receiving components" + ) + # Check by warehouse + self.assertPotentialQty( + self.tmpl.with_context(warehouse_id=self.wh_main.id), + 250.0, + "Wrong potential quantity in main WH", + ) + self.tmpl.invalidate_recordset() + self.assertPotentialQty( + self.tmpl.with_context(warehouse_id=self.wh_ch.id), + 213.0, + "Wrong potential quantity in Company2's WH", + ) + # Check by location + self.assertPotentialQty( + self.tmpl.with_context(location=self.wh_main.lot_stock_id.id), + 250.0, + "Wrong potential quantity in main WH location", + ) + self.assertPotentialQty( + self.tmpl.with_context(location=self.wh_ch.lot_stock_id.id), + 213.0, + "Wrong potential quantity in Company2's WH location", + ) + + def test_04_multi_unit_recursive_bom(self): + # Test multi-level and multi-units BOM + uom_unit = self.env.ref("uom.product_uom_unit") + uom_unit.rounding = 1.0 + p1 = self.product_model.create( + { + "name": "Test product with BOM", + "type": "consu", + "is_storable": True, + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + p2 = self.product_model.create( + { + "name": "Test sub product with BOM", + "type": "consu", + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + p3 = self.product_model.create( + { + "name": "Test component", + "type": "consu", + "is_storable": True, + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + bom_p1 = self.bom_model.create( + {"product_tmpl_id": p1.product_tmpl_id.id, "product_id": p1.id} + ) + + self.bom_line_model.create( + { + "bom_id": bom_p1.id, + "product_id": p3.id, + "product_qty": 1, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + # Two p2 which have a bom + self.bom_line_model.create( + { + "bom_id": bom_p1.id, + "product_id": p2.id, + "product_qty": 2, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + bom_p2 = self.bom_model.create( + { + "product_tmpl_id": p2.product_tmpl_id.id, + "product_id": p2.id, + "type": "phantom", + } + ) + + # p2 need 2 unit of component + self.bom_line_model.create( + { + "bom_id": bom_p2.id, + "product_id": p3.id, + "product_qty": 2, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + p1.invalidate_model() + + # Need a least 5 units for one P1 + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3, 1) + p1.invalidate_model() + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3, 3) + p1.invalidate_model() + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3, 5) + p1.invalidate_model() + self.assertEqual(1.0, p1.potential_qty) + + self.create_inventory(p3, 6) + p1.invalidate_model() + self.assertEqual(3.0, p1.potential_qty) + + self.create_inventory(p3, 10) + p1.invalidate_model() + self.assertEqual(5.0, p1.potential_qty) + + def test_empty_component_needs(self): + product_with_bom = [Mock()] + product_with_bom[0].bom_ids = [Mock()] + + product_with_bom[0]._get_components_needs.return_value = {} + + product_with_bom[0].potential_qty = 0.0 + + for product in product_with_bom: + exploded_components = {} + component_needs = product._get_components_needs(exploded_components) + + self.assertEqual(component_needs, {}, "Component needs should be empty") + self.assertEqual( + product.potential_qty, 0.0, "Potential quantity should be 0.0" + ) + + def test_product_phantom(self): + # Create a BOM product with 2 components + # Set stock quantity for the first one == 0.0 + # Set stock quantity for the second one == 1.0 + # Create an incoming movement for the first component + # The immediately available quantity should stay == 0.0 + uom_unit = self.env.ref("uom.product_uom_unit") + uom_unit.rounding = 1.0 + product = self.product_model.create( + { + "name": "Test product with BOM", + "type": "consu", + "is_storable": True, + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + bom = self.bom_model.create( + { + "product_tmpl_id": product.product_tmpl_id.id, + "product_id": product.id, + "type": "phantom", + } + ) + + bom_product = self.product_model.create( + { + "name": "BOM product", + "type": "consu", + "is_storable": True, + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + self.bom_line_model.create( + { + "bom_id": bom.id, + "product_id": bom_product.id, + "product_qty": 3, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + bom_product_2 = self.product_model.create( + { + "name": "BOM product 2", + "type": "consu", + "is_storable": True, + "uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + + self.bom_line_model.create( + { + "bom_id": bom.id, + "product_id": bom_product_2.id, + "product_qty": 1, + "product_uom_id": self.env.ref("uom.product_uom_unit").id, + } + ) + self.create_inventory(bom_product_2, 1) + + move_in = self.env["stock.move"].create( + { + "name": bom_product.name, + "location_id": self.env.ref("stock.stock_location_suppliers").id, + "location_dest_id": self.env.ref("stock.stock_location_stock").id, + "product_id": bom_product.id, + "product_uom_qty": 1.0, + "product_uom": self.env.ref("uom.product_uom_unit").id, + } + ) + + move_in._action_confirm() + product.invalidate_model() + + self.assertEqual(product.immediately_usable_qty, 0.0) + + def test_06_potential_qty(self): + # BoM only applies to white variant. + bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.tmpl.id)]) + bom.bom_line_ids.write({"bom_product_template_attribute_value_ids": False}) + bom.product_id = self.var2.id + for i in [self.tmpl, self.var1, self.var2]: + self.assertPotentialQty(i, 0.0, "The potential quantity should start at 0") + + # Receive 1000x Wood Panel + self.create_inventory( + product=self.env.ref("mrp.product_product_wood_panel"), + qty=1000.0, + location=self.wh_main.lot_stock_id, + ) + for i in [self.tmpl, self.var1, self.var2]: + self.assertPotentialQty( + i, + 0.0, + "Receiving a single component should not change the " + f"potential of {i}", + ) + + # Receive second component + self.create_inventory( + product=self.env.ref("mrp.product_product_computer_desk_bolt"), + qty=1000.0, + location=self.wh_main.lot_stock_id, + ) + self.assertPotentialQty( + self.tmpl, + 0, + "Template potential changed after receiving partial variant 2 components", + ) + self.assertPotentialQty( + self.var1, + 0, + "Variant 1 potential changed after receiving partial variant 2 components", + ) + self.assertPotentialQty( + self.var2, + 0.0, + "Variant 2 potential changed after receiving partial components", + ) + + # Receive enough components to make 250 the 1st variant + self.create_inventory( + product=self.env.ref( + "stock_available_mrp.product_computer_desk_bolt_white" + ), + qty=1000.0, + location=self.wh_main.lot_stock_id, + ) + self.var1.invalidate_model() + self.assertPotentialQty( + self.tmpl, + 250.0, + "Wrong template potential after receiving variant 2 components", + ) + self.assertPotentialQty( + self.var1, + 0, + "Wrong variant 1 potential after receiving variant 2 components", + ) + self.assertPotentialQty( + self.var2, 250.0, "Wrong variant 2 potential after receiving its components" + ) diff --git a/stock_available_mrp/views/res_config_settings_views.xml b/stock_available_mrp/views/res_config_settings_views.xml new file mode 100644 index 00000000..bf721127 --- /dev/null +++ b/stock_available_mrp/views/res_config_settings_views.xml @@ -0,0 +1,20 @@ + + + + Stock settings: quantity available to promise + res.config.settings + + + + + + + + + + + +