summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorWilliam Henrotin <whe@odoo.com>2019-08-21 10:06:49 +0000
committerWilliam Henrotin <whe@odoo.com>2019-08-21 12:22:53 +0000
commit2137e45bb5e5bd28e6f14a1c4b269d1e63b4f7ab (patch)
tree445067460b631ccf9be1fcb7e61c17cba066c264 /addons
parent60f2262df7b19730ce343a3f70e640a7555c7eed (diff)
[IMP] stock, mrp: do not compute quantities on service product
This commit avoid searching into quants and stock.moves, the quantities (available, forecasted, ...), for service product in order to speedup the search on big recordset closes odoo/odoo#35920 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mrp/models/mrp_bom.py2
-rw-r--r--addons/stock/models/product.py11
2 files changed, 11 insertions, 2 deletions
diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py
index b6fedb9a79b..0a66b1f04e8 100644
--- a/addons/mrp/models/mrp_bom.py
+++ b/addons/mrp/models/mrp_bom.py
@@ -141,6 +141,8 @@ class MrpBom(models.Model):
@api.model
def _bom_find(self, product_tmpl=None, product=None, picking_type=None, company_id=False, bom_type=False):
""" Finds BoM for particular product, picking and company """
+ if product and product.type == 'service' or product_tmpl and product_tmpl.type == 'service':
+ return False
domain = self._bom_find_domain(product_tmpl=product_tmpl, product=product, picking_type=picking_type, company_id=company_id, bom_type=bom_type)
if domain is False:
return domain
diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py
index c0f5e5cca4f..cd838f35c93 100644
--- a/addons/stock/models/product.py
+++ b/addons/stock/models/product.py
@@ -94,13 +94,20 @@ class Product(models.Model):
'company_owned', 'location', 'warehouse', 'force_company',
)
def _compute_quantities(self):
- res = self._compute_quantities_dict(self._context.get('lot_id'), self._context.get('owner_id'), self._context.get('package_id'), self._context.get('from_date'), self._context.get('to_date'))
- for product in self:
+ products = self.filtered(lambda p: p.type != 'service')
+ res = products._compute_quantities_dict(self._context.get('lot_id'), self._context.get('owner_id'), self._context.get('package_id'), self._context.get('from_date'), self._context.get('to_date'))
+ for product in products:
product.qty_available = res[product.id]['qty_available']
product.incoming_qty = res[product.id]['incoming_qty']
product.outgoing_qty = res[product.id]['outgoing_qty']
product.virtual_available = res[product.id]['virtual_available']
product.free_qty = res[product.id]['free_qty']
+ for product in self - products:
+ product.qty_available = 0.0
+ product.incoming_qty = 0.0
+ product.outgoing_qty = 0.0
+ product.virtual_available = 0.0
+ product.free_qty = 0.0
def _product_available(self, field_names=None, arg=False):
""" Compatibility method """