mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
stock_available / stock_available_mrp : add possibility to choose which field use to compute potential
This commit is contained in:
committed by
Florian da Costa
parent
f31bdb5bb6
commit
c23889e8ba
@@ -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
|
||||
=====
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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()]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user