Merge pull request #142 from gurneyalex/9.0-update-stock_available_immediately

[9.0] update stock_available / stock_available_immediately
This commit is contained in:
Pedro M. Baeza
2016-03-22 10:53:54 +01:00
7 changed files with 66 additions and 14 deletions

View File

@@ -4,7 +4,7 @@
{
'name': 'Stock available to promise',
'version': '9.0.1.0.0',
'version': '9.0.1.0.1',
"author": "Numérigraphe, Sodexis, Odoo Community Association (OCA)",
'category': 'Warehouse',
'depends': ['stock'],

View File

@@ -14,16 +14,20 @@ class ProductProduct(models.Model):
"""
_inherit = 'product.product'
@api.one
@api.multi
@api.depends('virtual_available')
def _immediately_usable_qty(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."""
self.immediately_usable_qty = self.virtual_available
**Each** sub-module **must** override this method in **both**
`product.product` **and** `product.template`, because we can't
decide in advance how to compute the template's quantity from the
variants.
"""
for prod in self:
prod.immediately_usable_qty = prod.virtual_available
immediately_usable_qty = fields.Float(
digits=dp.get_precision('Product Unit of Measure'),

View File

@@ -9,12 +9,20 @@ from openerp.addons import decimal_precision as dp
class ProductTemplate(models.Model):
_inherit = 'product.template'
@api.one
@api.depends('virtual_available')
@api.multi
@api.depends('product_variant_ids.immediately_usable_qty')
def _immediately_usable_qty(self):
"""Compute the quantity using all the variants"""
self.immediately_usable_qty = sum(
[v.immediately_usable_qty for v in self.product_variant_ids])
"""No-op implementation of the stock available to promise.
By default, available to promise = forecasted quantity.
**Each** sub-module **must** override this method in **both**
`product.product` **and** `product.template`, because we can't
decide in advance how to compute the template's quantity from the
variants.
"""
for tmpl in self:
tmpl.immediately_usable_qty = tmpl.virtual_available
immediately_usable_qty = fields.Float(
digits=dp.get_precision('Product Unit of Measure'),

View File

@@ -4,7 +4,7 @@
{
"name": "Ignore planned receptions in quantity available to promise",
"version": "9.0.1.0.0",
"version": "9.0.1.1.0",
"depends": ["stock_available"],
"author": "Camptocamp,Sodexis,Odoo Community Association (OCA)",
"license": "AGPL-3",

View File

@@ -3,3 +3,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import product_product
from . import product_template

View File

@@ -8,8 +8,12 @@ from openerp import models, api
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.one
@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _immediately_usable_qty(self):
"""Ignore the incoming goods in the quantity available to promise"""
"""Ignore the incoming goods in the quantity available to promise
This is the same implementation as for templates."""
super(ProductProduct, self)._immediately_usable_qty()
self.immediately_usable_qty -= self.incoming_qty
for prod in self:
prod.immediately_usable_qty -= prod.incoming_qty

View File

@@ -0,0 +1,35 @@
# -*- 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _immediately_usable_qty(self):
"""Ignore the incoming goods in the quantity available to promise
This is the same implementation as for variants."""
super(ProductTemplate, self)._immediately_usable_qty()
for tmpl in self:
tmpl.immediately_usable_qty -= tmpl.incoming_qty