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 f31bdb5bb6
commit c23889e8ba
3 changed files with 12 additions and 2 deletions

View File

@@ -9,6 +9,9 @@ Consider the production potential is available to promise
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.
Usage
=====

View File

@@ -3,7 +3,7 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Consider the production potential is available to promise',
'version': '8.0.3.0.1',
'version': '8.0.3.1.0',
"author": u"Numérigraphe,"
u"Odoo Community Association (OCA)",
'category': 'Hidden',

View File

@@ -6,6 +6,7 @@ from collections import Counter
from openerp import models, fields, api
from openerp.addons import decimal_precision as dp
from openerp.tools.safe_eval import safe_eval
class ProductProduct(models.Model):
@@ -35,6 +36,12 @@ class ProductProduct(models.Model):
bom_obj = self.env['mrp.bom']
uom_obj = self.env['product.uom']
icp = self.env['ir.config_parameter']
stock_available_mrp_based_on = safe_eval(
icp.get_param('stock_available_mrp_based_on', 'False'))
if not stock_available_mrp_based_on:
stock_available_mrp_based_on = 'qty_available'
for product in self:
bom_id = bom_obj._bom_find(product_id=product.id)
if not bom_id:
@@ -53,7 +60,7 @@ class ProductProduct(models.Model):
else:
# Find the lowest quantity we can make with the stock at hand
components_potential_qty = min(
[component.qty_available // need
[getattr(component, stock_available_mrp_based_on) // need
for component, need in component_needs.items()]
)