mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[10.0][CHG]stock_available...: improve stock methods computation
optimize stock computation by avoiding to call useless compute
This commit is contained in:
committed by
Florian da Costa
parent
7454d8e84e
commit
ba9b10f36f
@@ -41,6 +41,7 @@ Contributors
|
||||
* Sébastien BEAU (Akretion) <sebastien.beau@akretion.com>
|
||||
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
|
||||
* Sodexis <sodexis@sodexis.com>
|
||||
* Cédric Pigeon <cedric.pigeon@acsone.eu>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
@@ -4,4 +4,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import product_product
|
||||
from . import product_template
|
||||
|
||||
@@ -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
|
||||
@@ -3,7 +3,7 @@
|
||||
# Copyright 2016 Sodexis
|
||||
# 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):
|
||||
@@ -11,11 +11,14 @@ class Product(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
@api.multi
|
||||
@api.depends('virtual_available', 'incoming_qty')
|
||||
def _compute_immediately_usable_qty(self):
|
||||
"""Ignore the incoming goods in the quantity available to promise
|
||||
def _compute_available_quantities_dict(self):
|
||||
res, stock_dict = super(ProductProduct,
|
||||
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."""
|
||||
super(ProductProduct, self)._compute_immediately_usable_qty()
|
||||
for prod in self:
|
||||
prod.immediately_usable_qty -= prod.incoming_qty
|
||||
@api.depends('virtual_available', 'incoming_qty')
|
||||
def _compute_available_quantities(self):
|
||||
return super(ProductProduct, self)._compute_available_quantities()
|
||||
|
||||
Reference in New Issue
Block a user