mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] corrected calculation of immediately_usable_qty on product.product and
product.template, now takes in account variants and correctly displays value. [FLAKE8] Removing duplicate modules and moving README.rst into __unported__
This commit is contained in:
@@ -22,16 +22,16 @@ from openerp import models, fields, api
|
||||
from openerp.addons import decimal_precision as dp
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
class Product(models.Model):
|
||||
"""Add a field for the stock available to promise.
|
||||
|
||||
Useful implementations need to be installed through the Settings menu or by
|
||||
installing one of the modules stock_available_*
|
||||
"""
|
||||
_inherit = 'product.template'
|
||||
_inherit = 'product.product'
|
||||
|
||||
@api.depends('virtual_available')
|
||||
def _product_available(self):
|
||||
def _immediately_usable_qty(self):
|
||||
"""No-op implementation of the stock available to promise.
|
||||
|
||||
By default, available to promise = forecasted quantity.
|
||||
@@ -43,7 +43,41 @@ class ProductTemplate(models.Model):
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
compute='_product_available',
|
||||
compute='_immediately_usable_qty',
|
||||
string='Available to promise',
|
||||
help="Stock for this Product that can be safely proposed "
|
||||
"for sale to Customers.\n"
|
||||
"The definition of this value can be configured to suit "
|
||||
"your needs")
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
"""Add a field for the stock available to promise.
|
||||
Useful implementations need to be installed through the Settings menu or by
|
||||
installing one of the modules stock_available_*
|
||||
"""
|
||||
_inherit = 'product.template'
|
||||
|
||||
@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."""
|
||||
product_model = self.env['product.product']
|
||||
for product_template in self:
|
||||
products = product_model.search([(
|
||||
'product_tmpl_id', '=', product_template.id)])
|
||||
qty = 0
|
||||
for product in products:
|
||||
qty += product.immediately_usable_qty
|
||||
product_template.immediately_usable_qty = qty
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
compute='_immediately_usable_qty',
|
||||
string='Available to promise',
|
||||
help="Stock for this Product that can be safely proposed "
|
||||
"for sale to Customers.\n"
|
||||
|
||||
@@ -19,18 +19,15 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api
|
||||
from openerp import models
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
class Product(models.Model):
|
||||
"""Subtract incoming qty from immediately_usable_qty"""
|
||||
_inherit = 'product.template'
|
||||
_inherit = 'product.product'
|
||||
|
||||
@api.depends('virtual_available')
|
||||
def _product_available(self):
|
||||
def _immediately_usable_qty(self):
|
||||
"""Ignore the incoming goods in the quantity available to promise"""
|
||||
super(ProductTemplate, self)._product_available()
|
||||
super(Product, self)._immediately_usable_qty()
|
||||
for product in self:
|
||||
product.immediately_usable_qty -= product.incoming_qty
|
||||
|
||||
immediately_usable_qty = fields.Float(compute='_product_available')
|
||||
|
||||
Reference in New Issue
Block a user