diff --git a/stock_available/README.rst b/stock_available/README.rst
index e2fd42825..01663154a 100644
--- a/stock_available/README.rst
+++ b/stock_available/README.rst
@@ -6,6 +6,8 @@ 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.
+In case of immediate production capacity, it is possible to configure on which
+field the potential is computed, by default Quantity On Hand is used.
This can be configured in the menu Settings > Configuration > Warehouse.
Configuration
@@ -16,6 +18,8 @@ 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`.
+In case of "Include the production potential", it is also possible to configure
+which field of product to use to compute the production potential.
Usage
=====
diff --git a/stock_available/__openerp__.py b/stock_available/__openerp__.py
index f5748a838..59319331b 100644
--- a/stock_available/__openerp__.py
+++ b/stock_available/__openerp__.py
@@ -4,7 +4,7 @@
{
'name': 'Stock available to promise',
- 'version': '9.0.1.0.1',
+ 'version': '9.0.1.1.0',
"author": "Numérigraphe, Sodexis, Odoo Community Association (OCA)",
'category': 'Warehouse',
'depends': ['stock'],
diff --git a/stock_available/models/res_config.py b/stock_available/models/res_config.py
index 11cc77614..51dffe4cd 100644
--- a/stock_available/models/res_config.py
+++ b/stock_available/models/res_config.py
@@ -2,7 +2,8 @@
# © 2014 Numérigraphe, Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-from openerp import models, fields
+from openerp import api, models, fields
+from openerp.tools.safe_eval import safe_eval
class StockConfig(models.TransientModel):
@@ -10,6 +11,14 @@ class StockConfig(models.TransientModel):
"""Add options to easily install the submodules"""
_inherit = 'stock.config.settings'
+ @api.model
+ def _get_stock_available_mrp_based_on(self):
+ """Gets the available languages for the selection."""
+ fields = self.env['ir.model.fields'].search(
+ [('model', '=', 'product.product'),
+ ('ttype', '=', 'float')])
+ return [(field.name, field.field_description) for field in fields]
+
module_stock_available_immediately = fields.Boolean(
string='Exclude incoming goods',
help="This will subtract incoming quantities from the quantities "
@@ -24,11 +33,35 @@ class StockConfig(models.TransientModel):
# "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")
+ 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")
+
+ stock_available_mrp_based_on = fields.Selection(
+ _get_stock_available_mrp_based_on,
+ string='based on',
+ help="Choose the field of the product which will be used to compute "
+ "potential.\nIf empty, Quantity On Hand is used.",
+ )
+
+ @api.model
+ def get_default_stock_available_mrp_based_on(self, fields):
+ res = {}
+ icp = self.env['ir.config_parameter']
+ res['stock_available_mrp_based_on'] = safe_eval(
+ icp.get_param('stock_available_mrp_based_on', 'False'))
+ if not res['stock_available_mrp_based_on']:
+ res['stock_available_mrp_based_on'] = 'qty_available'
+ return res
+
+ @api.multi
+ def set_stock_available_mrp_based_on(self):
+ if self.stock_available_mrp_based_on:
+ icp = self.env['ir.config_parameter']
+ icp.set_param('stock_available_mrp_based_on',
+ repr(self.stock_available_mrp_based_on))
diff --git a/stock_available/views/res_config_view.xml b/stock_available/views/res_config_view.xml
index 51eaca46f..d9b06a564 100644
--- a/stock_available/views/res_config_view.xml
+++ b/stock_available/views/res_config_view.xml
@@ -23,10 +23,12 @@
-->
-
+
+
+