diff --git a/setup/stock_available_mrp/odoo/addons/stock_available_mrp b/setup/stock_available_mrp/odoo/addons/stock_available_mrp new file mode 120000 index 000000000..cd15a8cae --- /dev/null +++ b/setup/stock_available_mrp/odoo/addons/stock_available_mrp @@ -0,0 +1 @@ +../../../../stock_available_mrp \ No newline at end of file diff --git a/setup/stock_available_mrp/setup.py b/setup/stock_available_mrp/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/stock_available_mrp/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_available_mrp/README.rst b/stock_available_mrp/README.rst new file mode 100644 index 000000000..0f9265f28 --- /dev/null +++ b/stock_available_mrp/README.rst @@ -0,0 +1,128 @@ +========================================================= +Consider the production potential is available to promise +========================================================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--warehouse-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-warehouse/tree/12.0/stock_available_mrp + :alt: OCA/stock-logistics-warehouse +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_available_mrp + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/153/12.0 + :alt: Try me on Runbot + +|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 smashing 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 + +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-warehouse `_ 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 000000000..2f72d6f91 --- /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 000000000..114ddfa8e --- /dev/null +++ b/stock_available_mrp/__manifest__.py @@ -0,0 +1,13 @@ +# 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": "13.0.1.0.0", + "author": "Numérigraphe," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-warehouse", + "category": "Hidden", + "depends": ["stock_available", "mrp"], + "demo": ["demo/mrp_data.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 000000000..4e7b818ed --- /dev/null +++ b/stock_available_mrp/demo/mrp_data.xml @@ -0,0 +1,47 @@ + + + + PCSC234-WHITE + + + + + + + + + + + Bolt + + 1.0 + 5.0 + product + + + BOLT-WHITE + + + + 4 + + 5 + + + + diff --git a/stock_available_mrp/i18n/de.po b/stock_available_mrp/i18n/de.po new file mode 100644 index 000000000..a38fea285 --- /dev/null +++ b/stock_available_mrp/i18n/de.po @@ -0,0 +1,70 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Produkt" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..07d39842f --- /dev/null +++ b/stock_available_mrp/i18n/es.po @@ -0,0 +1,66 @@ +# 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: 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" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Producto" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..7c821407d --- /dev/null +++ b/stock_available_mrp/i18n/fi.po @@ -0,0 +1,66 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Tuote" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..faf91b5ca --- /dev/null +++ b/stock_available_mrp/i18n/fr.po @@ -0,0 +1,67 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "Nomenclature" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: 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,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Article" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "Table en kit" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "Table en kit" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "Unité(s)" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "kg" + +#~ 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 000000000..c81966fc3 --- /dev/null +++ b/stock_available_mrp/i18n/hr_HR.po @@ -0,0 +1,97 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Proizvod" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..ecf95c695 --- /dev/null +++ b/stock_available_mrp/i18n/it.po @@ -0,0 +1,63 @@ +# 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: 2016-04-27 11:10+0000\n" +"Last-Translator: <>\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" + +#. module: stock_available_mrp +#: model:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Prodotto" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" diff --git a/stock_available_mrp/i18n/pt_BR.po b/stock_available_mrp/i18n/pt_BR.po new file mode 100644 index 000000000..c7257894b --- /dev/null +++ b/stock_available_mrp/i18n/pt_BR.po @@ -0,0 +1,95 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Produto" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..9f62571ce --- /dev/null +++ b/stock_available_mrp/i18n/sl.po @@ -0,0 +1,71 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "Proizvod" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + +#~ 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 000000000..3ea2293db --- /dev/null +++ b/stock_available_mrp/i18n/stock_available_mrp.pot @@ -0,0 +1,59 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_available_mrp +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "" + diff --git a/stock_available_mrp/i18n/zh_CN.po b/stock_available_mrp/i18n/zh_CN.po new file mode 100644 index 000000000..07f53d170 --- /dev/null +++ b/stock_available_mrp/i18n/zh_CN.po @@ -0,0 +1,77 @@ +# 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:ir.model.fields,field_description:stock_available_mrp.field_product_product__bom_id +msgid "BOM" +msgstr "BOM" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.template,name:stock_available_mrp.product_computer_desk_bolt_white_product_template +msgid "Bolt" +msgstr "螺栓" + +#. module: stock_available_mrp +#: model:ir.model,name:stock_available_mrp.model_product_product +msgid "Product" +msgstr "产品" + +#. module: stock_available_mrp +#: model:product.product,name:stock_available_mrp.product_kit_1a +#: model:product.template,name:stock_available_mrp.product_kit_1a_product_template +msgid "Table Kit" +msgstr "桌台套件" + +#. module: stock_available_mrp +#: model:product.product,description:stock_available_mrp.product_kit_1a +#: model:product.template,description:stock_available_mrp.product_kit_1a_product_template +msgid "Table kit" +msgstr "桌台套件" + +#. module: stock_available_mrp +#: model:product.product,uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "Unit(s)" +msgstr "件" + +#. module: stock_available_mrp +#: model:product.product,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white +#: model:product.product,weight_uom_name:stock_available_mrp.product_kit_1a +#: model:product.template,weight_uom_name:stock_available_mrp.product_computer_desk_bolt_white_product_template +#: model:product.template,weight_uom_name:stock_available_mrp.product_kit_1a_product_template +msgid "kg" +msgstr "公斤" + +#~ msgid "Product Template" +#~ msgstr "产品模板" + +#~ msgid "Potential" +#~ msgstr "潜在" + +#~ msgid "Potential" +#~ msgstr "潜在" + +#~ msgid "Thousand" +#~ msgstr "千" diff --git a/stock_available_mrp/models/__init__.py b/stock_available_mrp/models/__init__.py new file mode 100644 index 000000000..bf91af2eb --- /dev/null +++ b/stock_available_mrp/models/__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 product_product diff --git a/stock_available_mrp/models/product_product.py b/stock_available_mrp/models/product_product.py new file mode 100644 index 000000000..fcd8af5c6 --- /dev/null +++ b/stock_available_mrp/models/product_product.py @@ -0,0 +1,139 @@ +# 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, fields, models +from odoo.fields import first + + +class ProductProduct(models.Model): + _inherit = "product.product" + + bom_id = fields.Many2one( + comodel_name="mrp.bom", compute="_compute_bom_id", string="BOM" + ) + + @api.depends("virtual_available", "bom_id", "bom_id.product_qty") + def _compute_available_quantities(self): + super()._compute_available_quantities() + + def _get_bom_id_domain(self): + """ + Real multi domain + :return: + """ + return [ + "|", + ("product_id", "in", self.ids), + "&", + ("product_id", "=", False), + ("product_tmpl_id", "in", self.mapped("product_tmpl_id.id")), + ] + + @api.depends("product_tmpl_id") + def _compute_bom_id(self): + bom_obj = self.env["mrp.bom"] + boms = bom_obj.search(self._get_bom_id_domain(), order="sequence, product_id") + for product in self: + product.bom_id = product.bom_id + product_boms = boms.filtered( + lambda b: b.product_id == product + or (not b.product_id and b.product_tmpl_id == product.product_tmpl_id) + ) + if product_boms: + product.bom_id = first(product_boms) + + 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("bom_id") + + 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_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 res and stock_available_mrp_based_on in list(res.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) + 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 = immediately_usable_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() + ] + ) + + 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. + potential_qty = bom_id.product_uom_id._compute_quantity( + potential_qty, + product.bom_id.product_tmpl_id.uom_id, + rounding_method="DOWN", + ) + + res[product.id]["potential_qty"] = potential_qty + immediately_usable_qty = potential_qty if bom_id.type != "phantom" else 0 + res[product.id]["immediately_usable_qty"] += immediately_usable_qty + + return res, stock_dict + + def _explode_boms(self): + """ + return a dict by product_id of exploded bom lines + :return: + """ + exploded_boms = {} + for rec in self: + exploded_boms[rec.id] = rec.bom_id.explode(rec, 1.0)[1] + return exploded_boms + + @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_component in exploded_components: + component = bom_component[0].product_id + needs += Counter({component: bom_component[1]["qty"]}) + + return needs diff --git a/stock_available_mrp/readme/CONTRIBUTORS.rst b/stock_available_mrp/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..1089a647b --- /dev/null +++ b/stock_available_mrp/readme/CONTRIBUTORS.rst @@ -0,0 +1,10 @@ +* 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 + +* `Tecnativa `_: + + * Víctor Martínez diff --git a/stock_available_mrp/readme/DESCRIPTION.rst b/stock_available_mrp/readme/DESCRIPTION.rst new file mode 100644 index 000000000..83df836a5 --- /dev/null +++ b/stock_available_mrp/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +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.rst b/stock_available_mrp/readme/ROADMAP.rst new file mode 100644 index 000000000..88ebb1f2e --- /dev/null +++ b/stock_available_mrp/readme/ROADMAP.rst @@ -0,0 +1,41 @@ +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 000000000..3a0328b51 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 000000000..7e01b1be9 --- /dev/null +++ b/stock_available_mrp/static/description/index.html @@ -0,0 +1,477 @@ + + + + + + +Consider the production potential is available to promise + + + +
+

Consider the production potential is available to promise

+ + +

Beta License: AGPL-3 OCA/stock-logistics-warehouse Translate me on Weblate Try me on Runbot

+

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 smashing 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-warehouse 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 000000000..4382bb886 --- /dev/null +++ b/stock_available_mrp/tests/__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 test_potential_qty 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 000000000..022e0f58c --- /dev/null +++ b/stock_available_mrp/tests/test_potential_qty.py @@ -0,0 +1,394 @@ +# 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 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""" + + def setUp(self): + super().setUp() + + self.product_model = self.env["product.product"] + self.bom_model = self.env["mrp.bom"] + self.bom_line_model = self.env["mrp.bom.line"] + self.stock_quant_model = self.env["stock.quant"] + self.config = self.env["ir.config_parameter"] + self.location = self.env["stock.location"] + self.main_company = self.browse_ref("base.main_company") + # Get the warehouses + self.wh_main = self.browse_ref("stock.warehouse0") + self.wh_ch = self.browse_ref("stock.stock_warehouse_shop0") + #  An interesting product (multi-line BoM, variants) + self.tmpl = self.browse_ref("mrp.product_product_table_kit_product_template") + #  First variant + self.var1 = self.browse_ref("mrp.product_product_table_kit") + #  Second variant + self.var2 = self.browse_ref("stock_available_mrp.product_kit_1a") + # 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 = self.env.ref("mrp.product_product_computer_desk_bolt") + bolt.stock_move_ids._do_unreserve() + bolt.type = "product" + # Components that can be used to make the product + components = [ + # Bolt + bolt, + # Wood Panel + self.browse_ref("mrp.product_product_wood_panel"), + ] + + # Zero-out the inventory of all variants and components + for component in components + [v for v in self.tmpl.product_variant_ids]: + component.stock_quant_ids.unlink() + + #  A product without a BoM + self.product_wo_bom = self.browse_ref("product.product_product_11") + + # Record the initial quantity available for sale + self.initial_usable_qties = { + i.id: i.immediately_usable_qty + for i in [self.tmpl, self.var1, self.var2, self.product_wo_bom] + } + + def _create_inventory(self, location_id, company_id): + inventory = self.env["stock.inventory"].create( + { + "name": "Test inventory", + "company_id": company_id, + "location_ids": [(4, location_id)], + "start_empty": True, + } + ) + inventory.action_start() + return inventory + + def _create_inventory_line(self, inventory_id, product_id, location_id, qty): + self.env["stock.inventory.line"].create( + { + "inventory_id": inventory_id, + "product_id": product_id, + "location_id": location_id, + "product_qty": qty, + } + ) + + def create_inventory(self, product_id, qty, location_id=None, company_id=None): + if location_id is None: + location_id = self.wh_main.lot_stock_id.id + + if company_id is None: + company_id = self.main_company.id + + inventory = self._create_inventory(location_id, company_id) + self._create_inventory_line(inventory.id, product_id, location_id, qty) + inventory._action_done() + + def create_simple_bom( + self, product, sub_product, product_qty=1, sub_product_qty=1, routing_id=False + ): + bom = self.bom_model.create( + { + "product_tmpl_id": product.product_tmpl_id.id, + "product_id": product.id, + "product_qty": product_qty, + "routing_id": routing_id, + } + ) + self.bom_line_model.create( + { + "bom_id": bom.id, + "product_id": sub_product.id, + "product_qty": sub_product_qty, + } + ) + + return bom + + def assertPotentialQty(self, record, qty, msg): + record.refresh() + # Check the potential + self.assertEqual(record.potential_qty, qty, msg) + # Check the variation of quantity available for sale + self.assertEqual( + (record.immediately_usable_qty - self.initial_usable_qties[record.id]), + qty, + msg, + ) + + def test_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_potential_qty_no_bom_for_company(self): + chicago_id = self.ref("stock.res_company_1") + # Receive 1000x Wood Panel owned by Chicago + self.create_inventory( + product_id=self.env.ref("mrp.product_product_wood_panel").id, + qty=1000.0, + location_id=self.wh_ch.lot_stock_id.id, + company_id=chicago_id, + ) + # Put Bolt owned by Chicago for 1000x the 1st variant in main WH + self.create_inventory( + product_id=self.env.ref("mrp.product_product_computer_desk_bolt").id, + qty=1000.0, + location_id=self.wh_ch.lot_stock_id.id, + company_id=chicago_id, + ) + 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": [(4, self.main_company.id), (4, chicago_id)], + "groups_id": [ + (4, self.ref("stock.group_stock_user")), + (4, self.ref("mrp.group_mrp_user")), + ], + } + ) + + bom = self.env["mrp.bom"].search([("product_tmpl_id", "=", self.tmpl.id)]) + + 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 Chicago (child of main company) + self.env["product.product"].search([TRUE_LEAF]).write({"company_id": False}) + test_user.write({"company_ids": [(6, 0, 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 = chicago_id + test_user.write({"company_ids": [(4, chicago_id)]}) + self.assertPotentialQty(test_user_tmpl, 250.0, "") + + def test_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_id=self.env.ref("mrp.product_product_wood_panel").id, + qty=1000.0, + location_id=self.wh_main.lot_stock_id.id, + ) + for i in [self.tmpl, self.var1, self.var2]: + self.assertPotentialQty( + i, + 0.0, + "Receiving a single component should not change the " + "potential of %s" % i, + ) + + # Receive enough bolt to make 1000x the 1st variant in main WH + self.create_inventory( + product_id=self.env.ref("mrp.product_product_computer_desk_bolt").id, + qty=1000.0, + location_id=self.wh_main.lot_stock_id.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 Chicago + inventory = self._create_inventory( + self.wh_ch.lot_stock_id.id, self.ref("stock.res_company_1") + ) + self._create_inventory_line( + inventory.id, + self.ref("mrp.product_product_wood_panel"), + self.wh_ch.lot_stock_id.id, + 1000.0, + ) + self._create_inventory_line( + inventory.id, + self.ref("stock_available_mrp.product_computer_desk_bolt_white"), + self.wh_ch.lot_stock_id.id, + 852.0, + ) + inventory._action_done() + 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=self.wh_main.id), + 250.0, + "Wrong potential quantity in main WH", + ) + self.assertPotentialQty( + self.tmpl.with_context(warehouse=self.wh_ch.id), + 213.0, + "Wrong potential quantity in Chicago 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 Chicago WH location", + ) + + def test_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": "product", + "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": "product", + "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.refresh() + + # Need a least 5 units for one P1 + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3.id, 1) + p1.refresh() + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3.id, 3) + p1.refresh() + self.assertEqual(0, p1.potential_qty) + + self.create_inventory(p3.id, 5) + p1.refresh() + self.assertEqual(1.0, p1.potential_qty) + + self.create_inventory(p3.id, 6) + p1.refresh() + self.assertEqual(1.0, p1.potential_qty) + + self.create_inventory(p3.id, 10) + p1.refresh() + self.assertEqual(2.0, p1.potential_qty) + + def test_potential_qty_list(self): + # Try to highlight a bug when _get_potential_qty is called on + # a recordset with multiple products + # Recursive compute is not working + + p1 = self.product_model.create({"name": "Test P1"}) + p2 = self.product_model.create({"name": "Test P2"}) + p3 = self.product_model.create({"name": "Test P3", "type": "product"}) + + self.config.set_param("stock_available_mrp_based_on", "immediately_usable_qty") + + # P1 need one P2 + self.create_simple_bom(p1, p2) + # P2 need one P3 + self.create_simple_bom(p2, p3) + + self.create_inventory(p3.id, 3) + + self.product_model.invalidate_cache() + + products = self.product_model.search([("id", "in", [p1.id, p2.id, p3.id])]) + + self.assertEqual( + {p1.id: 3.0, p2.id: 3.0, p3.id: 0.0}, + {p.id: p.potential_qty for p in products}, + )