[10.0][CHG]stock_available...: improve stock methods computation

optimize stock computation by avoiding to call useless compute
This commit is contained in:
Cédric Pigeon
2017-05-09 12:35:23 +02:00
committed by Florian da Costa
parent 7454d8e84e
commit ba9b10f36f
4 changed files with 13 additions and 30 deletions

View File

@@ -41,6 +41,7 @@ Contributors
* Sébastien BEAU (Akretion) <sebastien.beau@akretion.com> * Sébastien BEAU (Akretion) <sebastien.beau@akretion.com>
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com> * Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
* Sodexis <sodexis@sodexis.com> * Sodexis <sodexis@sodexis.com>
* Cédric Pigeon <cedric.pigeon@acsone.eu>
Maintainer Maintainer
---------- ----------

View File

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

View File

@@ -1,20 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2014 Camptocamp, Akretion, Numérigraphe
# Copyright 2016 Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api
class ProductTemplate(models.Model):
_inherit = 'product.template'
@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _compute_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)._compute_immediately_usable_qty()
for tmpl in self:
tmpl.immediately_usable_qty -= tmpl.incoming_qty

View File

@@ -3,7 +3,7 @@
# Copyright 2016 Sodexis # Copyright 2016 Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api from odoo import api, models
class Product(models.Model): class Product(models.Model):
@@ -11,11 +11,14 @@ class Product(models.Model):
_inherit = 'product.product' _inherit = 'product.product'
@api.multi @api.multi
@api.depends('virtual_available', 'incoming_qty') def _compute_available_quantities_dict(self):
def _compute_immediately_usable_qty(self): res, stock_dict = super(ProductProduct,
"""Ignore the incoming goods in the quantity available to promise self)._compute_available_quantities_dict()
for product in self:
res[product.id]['immediately_usable_qty'] -= \
stock_dict[product.id]['incoming_qty']
return res, stock_dict
This is the same implementation as for templates.""" @api.depends('virtual_available', 'incoming_qty')
super(ProductProduct, self)._compute_immediately_usable_qty() def _compute_available_quantities(self):
for prod in self: return super(ProductProduct, self)._compute_available_quantities()
prod.immediately_usable_qty -= prod.incoming_qty