stock_available / stock_available_mrp : add possibility to choose which field use to compute potential

This commit is contained in:
Laetitia Gangloff
2016-03-04 11:03:16 +01:00
committed by Florian da Costa
parent a92ddff38b
commit 6576d1fb2c
4 changed files with 51 additions and 12 deletions

View File

@@ -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
=====

View File

@@ -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'],

View File

@@ -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))

View File

@@ -23,10 +23,12 @@
<field name="module_stock_available_sale" class="oe_inline" />
<label for="module_stock_available_sale" />
</div> -->
<!-- <div>
<div>
<field name="module_stock_available_mrp" class="oe_inline" />
<label for="module_stock_available_mrp" />
</div> -->
<label for="stock_available_mrp_based_on" />
<field name="stock_available_mrp_based_on" class="oe_inline" attrs="{'required':[('module_stock_available_mrp','=',True)]}"/>
</div>
</div>
</group>
</xpath>