mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
Merge pull request #92 from gurneyalex/8.0-stock_available_improvements
product_available improvements
This commit is contained in:
@@ -29,7 +29,7 @@ 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.
|
||||
@@ -38,7 +38,8 @@ class ProductProduct(models.Model):
|
||||
|
||||
Must be overridden by another module that actually implement
|
||||
computations."""
|
||||
self.immediately_usable_qty = self.virtual_available
|
||||
for prod in self:
|
||||
prod.immediately_usable_qty = prod.virtual_available
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
|
||||
@@ -25,12 +25,15 @@ 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])
|
||||
for tmpl in self:
|
||||
tmpl.immediately_usable_qty = sum(
|
||||
v.immediately_usable_qty
|
||||
for v in tmpl.product_variant_ids
|
||||
)
|
||||
|
||||
immediately_usable_qty = fields.Float(
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
|
||||
@@ -25,8 +25,10 @@ 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"""
|
||||
super(ProductProduct, self)._immediately_usable_qty()
|
||||
self.immediately_usable_qty -= self.incoming_qty
|
||||
for prod in self:
|
||||
prod.immediately_usable_qty -= prod.incoming_qty
|
||||
|
||||
Reference in New Issue
Block a user