[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>
This commit is contained in:
William Henrotin
2019-08-21 12:22:53 +00:00
parent 60f2262df7
commit 2137e45bb5
2 changed files with 11 additions and 2 deletions
+2
View File
@@ -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
+9 -2
View File
@@ -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 """