From 8da242ce157ab56a6ba0c513d56c504b7285f1e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lionel=20Sausin=20=28Num=C3=A9rigraphe=29?= Date: Fri, 27 Feb 2015 13:43:56 +0100 Subject: [PATCH] [ADD] stock_available Generic module to compute the stock quantity available to promise using several implementations. stock_available_immediatly is changed to become the first optional implementation. Cherry pick of commit 0b060f619fa5d60f9fb343afe1154acd5c730148 from the v7 branch [IMP] stock_available* uses new API [ADD] stock_available_mrp Module to take immediate manufaturing capability into account in the stock quantity available to promise. Conflicts: stock_available/res_config.py [DEL] move stock_available_mrp to __unported__ [ADD] stock_available_sale Take sale quotations into account in the stock quantity available to promise Cherry-picked from 497068f5f5f1d65fdd4a6e90a787eba37b4e3232 Conflicts: stock_available/res_config.py [DEL] move stock_available_sale to __unported__ [IMP] READMEs and TODOs Cherry-picked from v7 at 8add4bea7e91924983fb29966e14a1f0d4d5332e Conflicts: __unported__/stock_available_mrp/__openerp__.py stock_available/__openerp__.py stock_available_immediately/__openerp__.py [IMP] respect product decimal precision https://github.com/odoo/odoo/issues/5512 and https://github.com/odoo-dev/odoo/commit/b3e5a940e3b67021173d07eb0c71c981a2fb9c78 makes it clear the standard intends to support decimal precision on the product form. --- stock_available/README.rst | 47 ++++++++++++ stock_available/__init__.py | 22 ++++++ stock_available/__openerp__.py | 32 ++++++++ stock_available/i18n/fr.po | 98 ++++++++++++++++++++++++ stock_available/i18n/stock_available.pot | 92 ++++++++++++++++++++++ stock_available/product.py | 51 ++++++++++++ stock_available/product_view.xml | 43 +++++++++++ stock_available/res_config.py | 49 ++++++++++++ stock_available/res_config_view.xml | 33 ++++++++ 9 files changed, 467 insertions(+) create mode 100644 stock_available/README.rst create mode 100644 stock_available/__init__.py create mode 100644 stock_available/__openerp__.py create mode 100644 stock_available/i18n/fr.po create mode 100644 stock_available/i18n/stock_available.pot create mode 100644 stock_available/product.py create mode 100644 stock_available/product_view.xml create mode 100644 stock_available/res_config.py create mode 100644 stock_available/res_config_view.xml diff --git a/stock_available/README.rst b/stock_available/README.rst new file mode 100644 index 000000000..e2b71b3be --- /dev/null +++ b/stock_available/README.rst @@ -0,0 +1,47 @@ +Stock available to promise +========================== + +This module proposes several options to compute the quantity available to +promise for each product. +This quantity is based on the projected stock and, depending on the +configuration, it can account for various data such as sales quotations or +immediate production capacity. +This can be configured in the menu Settings > Configuration > Warehouse. + +Configuration +============= + +By default, this module computes the stock available to promise as the virtual +stock. +To take davantage of the additional features, you must which information you +want to base the computation, by checking one or more boxes in the settings: +`Configuration` > `Warehouse` > `Stock available to promise`. + +Usage +===== + +This module adds a field named `Available for sale` on the Product form. +Various additional fields may be added, depending on which information you +chose to base the computation on. + +Credits +======= + +Contributors +------------ + +* Lionel Sausin (Numérigraphe) +* many others contributed to sub-modules, please refer to each sub-module's credits + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/stock_available/__init__.py b/stock_available/__init__.py new file mode 100644 index 000000000..6dff1269a --- /dev/null +++ b/stock_available/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import product +from . import res_config diff --git a/stock_available/__openerp__.py b/stock_available/__openerp__.py new file mode 100644 index 000000000..608e6b8f4 --- /dev/null +++ b/stock_available/__openerp__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Stock available to promise', + 'version': '8.0.2.0.0', + "author": u"Numérigraphe,Odoo Community Association (OCA)", + 'category': 'Warehouse', + 'depends': ['stock'], + 'license': 'AGPL-3', + 'data': [ + 'product_view.xml', + 'res_config_view.xml', + ] +} diff --git a/stock_available/i18n/fr.po b/stock_available/i18n/fr.po new file mode 100644 index 000000000..6c8e4c244 --- /dev/null +++ b/stock_available/i18n/fr.po @@ -0,0 +1,98 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-30 16:42+0000\n" +"PO-Revision-Date: 2014-07-30 16:42+0000\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 +#: field:product.product,immediately_usable_qty:0 +msgid "Available to promise" +msgstr "Disponible à la vente" + +#. module: stock_available +#: view:product.product:0 +msgid "Available to promise:" +msgstr "Disponible à la vente:" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_sale:0 +msgid "Exclude goods already in sale quotations" +msgstr "Exclure les marchandises qui sont déjà dans les devis" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_immediately:0 +msgid "Exclude incoming goods" +msgstr "Exclure les receptions attendues" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_mrp:0 +msgid "Include the production potential" +msgstr "Inclure la production potentielle" + +#. module: stock_available +#: code:_description:0 +#: model:ir.model,name:stock_available.model_product_product +#, python-format +msgid "Product" +msgstr "Article" + +#. module: stock_available +#: view:stock.config.settings:0 +msgid "Stock available to promise" +msgstr "Stock disponible à la vente" + +#. module: stock_available +#: help:product.product,immediately_usable_qty:0 +msgid "Stock for this Product that can be safely proposed for sale to Customers.\n" +"The definition of this value can be configured to suit your needs" +msgstr "Stock de cet article qui peut sans risque être proposé à la vente aux clients.\n" +"La définition de cette valeur est paramétrable selon vos besoins" + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_mrp:0 +msgid "This will add the quantities of goods that can be immediately manufactured, to the quantities available to promise.\n" +"This installs the module stock_available_mrp.\n" +"If the module mrp is not installed, this will install it too" +msgstr "Ceci ajoute les quantités de marchandises qui peuvent être immédiatement fabriquées, aux quantitiés disponibles à la vente.\n" +"Ceci installe le module stock_available_mrp.\n" +"Si le module mrp n'est pas encore installé, il le sera aussi" + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_immediately:0 +msgid "This will subtract incoming quantities from the quantities available to promise.\n" +"This installs the module stock_available_immediately." +msgstr "Ceci soustrait les réceptions attendues des quantitiés disponibles à la vente.\n" +"Ceci installe le module stock_available_immediately." + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_sale:0 +msgid "This will subtract quantities from the sale quotations from the quantities available to promise.\n" +"This installs the modules stock_available_sale.\n" +"If the modules sale and sale_delivery_date are not installed, this will install them too" +msgstr "Ceci soustrait les quantités des devis de vente des quantitiés disponibles à la vente.\n" +"Ceci installe le modules stock_available_sale.\n" +"Si les modules sale et sale_delivery_date ne sont pas encore installés, ils le seront également" + +#. module: stock_available +#: view:product.product:0 +msgid "red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete')" +msgstr "red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete')" + +#. module: stock_available +#: code:_description:0 +#: model:ir.model,name:stock_available.model_stock_config_settings +#, python-format +msgid "stock.config.settings" +msgstr "stock.config.settings" + diff --git a/stock_available/i18n/stock_available.pot b/stock_available/i18n/stock_available.pot new file mode 100644 index 000000000..6eed1c952 --- /dev/null +++ b/stock_available/i18n/stock_available.pot @@ -0,0 +1,92 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * stock_available +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-07-30 16:48+0000\n" +"PO-Revision-Date: 2014-07-30 16:48+0000\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 +#: field:product.product,immediately_usable_qty:0 +msgid "Available to promise" +msgstr "" + +#. module: stock_available +#: view:product.product:0 +msgid "Available to promise:" +msgstr "" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_sale:0 +msgid "Exclude goods already in sale quotations" +msgstr "" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_immediately:0 +msgid "Exclude incoming goods" +msgstr "" + +#. module: stock_available +#: field:stock.config.settings,module_stock_available_mrp:0 +msgid "Include the production potential" +msgstr "" + +#. module: stock_available +#: code:_description:0 +#: model:ir.model,name:stock_available.model_product_product +#, python-format +msgid "Product" +msgstr "" + +#. module: stock_available +#: view:stock.config.settings:0 +msgid "Stock available to promise" +msgstr "" + +#. module: stock_available +#: help:product.product,immediately_usable_qty:0 +msgid "Stock for this Product that can be safely proposed for sale to Customers.\n" +"The definition of this value can be configured to suit your needs" +msgstr "" + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_mrp:0 +msgid "This will add the quantities of goods that can be immediately manufactured, to the quantities available to promise.\n" +"This installs the module stock_available_mrp.\n" +"If the module mrp is not installed, this will install it too" +msgstr "" + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_immediately:0 +msgid "This will subtract incoming quantities from the quantities available to promise.\n" +"This installs the module stock_available_immediately." +msgstr "" + +#. module: stock_available +#: help:stock.config.settings,module_stock_available_sale:0 +msgid "This will subtract quantities from the sale quotations from the quantities available to promise.\n" +"This installs the modules stock_available_sale.\n" +"If the modules sale and sale_delivery_date are not installed, this will install them too" +msgstr "" + +#. module: stock_available +#: view:product.product:0 +msgid "red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete')" +msgstr "" + +#. module: stock_available +#: code:_description:0 +#: model:ir.model,name:stock_available.model_stock_config_settings +#, python-format +msgid "stock.config.settings" +msgstr "" + diff --git a/stock_available/product.py b/stock_available/product.py new file mode 100644 index 000000000..1a3b72a59 --- /dev/null +++ b/stock_available/product.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields, api +from openerp.addons import decimal_precision as dp + + +class ProductTemplate(models.Model): + """Add a field for the stock available to promise. + + Useful implementations need to be installed through the Settings menu or by + installing one of the modules stock_available_* + """ + _inherit = 'product.template' + + @api.depends('virtual_available') + def _product_available(self): + """No-op implementation of the stock available to promise. + + By default, available to promise = forecasted quantity. + + Must be overridden by another module that actually implement + computations.""" + for product in self: + product.immediately_usable_qty = product.virtual_available + + immediately_usable_qty = fields.Float( + digits=dp.get_precision('Product Unit of Measure'), + compute='_product_available', + string='Available to promise', + help="Stock for this Product that can be safely proposed " + "for sale to Customers.\n" + "The definition of this value can be configured to suit " + "your needs") diff --git a/stock_available/product_view.xml b/stock_available/product_view.xml new file mode 100644 index 000000000..d05270f75 --- /dev/null +++ b/stock_available/product_view.xml @@ -0,0 +1,43 @@ + + + + + Quantity available to promise (form) + product.template + + + + + + + + + + + Quantity available to promise (tree) + product.template + + + + + red:immediately_usable_qty<0;blue:immediately_usable_qty>=0 and state in ('draft', 'end', 'obsolete');black:immediately_usable_qty>=0 and state not in ('draft', 'end', 'obsolete') + + + + + + + + + + Quantity available to promise (kanban) + product.template + + + +
  • Available to promise:
  • +
    +
    +
    +
    +
    diff --git a/stock_available/res_config.py b/stock_available/res_config.py new file mode 100644 index 000000000..a07c9552a --- /dev/null +++ b/stock_available/res_config.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields + + +class StockConfig(models.TransientModel): + """Add options to easily install the submodules""" + _inherit = 'stock.config.settings' + + module_stock_available_immediately = fields.Boolean( + string='Exclude incoming goods', + help="This will subtract incoming quantities from the quantities " + "available to promise.\n" + "This installs the module stock_available_immediately.") + +# module_stock_available_sale = fields.Boolean( +# string='Exclude goods already in sale quotations', +# help="This will subtract quantities from the sale quotations from " +# "the quantities available to promise.\n" +# "This installs the modules stock_available_sale.\n" +# "If the modules sale and sale_delivery_date are not " +# "installed, this will install them too") + +# module_stock_available_mrp = fields.Boolean( +# string='Include the production potential', +# help="This will add the quantities of goods that can be " +# "immediately manufactured, to the quantities available to " +# "promise.\n" +# "This installs the module stock_available_mrp.\n" +# "If the module mrp is not installed, this will install it " +# "too") diff --git a/stock_available/res_config_view.xml b/stock_available/res_config_view.xml new file mode 100644 index 000000000..850355b67 --- /dev/null +++ b/stock_available/res_config_view.xml @@ -0,0 +1,33 @@ + + + + + Stock settings: quantity available to promise + stock.config.settings + + + + + + + + + + + + \ No newline at end of file