[FIX] stock,sale_stock: Speed up sale_order confirmation

In case there is a lot of stock_moves and/or lot of
stock_quants, the function _get_qty_procurement
takes a lot of time because there is no index defined
on most accessed fields.

I.E. OPW-2027183

closes odoo/odoo#36113

Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
This commit is contained in:
jev-odoo
2019-09-04 12:03:22 +00:00
parent dde5227546
commit 2761393b06
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ class StockLocationRoute(models.Model):
class StockMove(models.Model):
_inherit = "stock.move"
sale_line_id = fields.Many2one('sale.order.line', 'Sale Line')
sale_line_id = fields.Many2one('sale.order.line', 'Sale Line', index=True)
@api.model
def _prepare_merge_moves_distinct_fields(self):
+2 -2
View File
@@ -20,7 +20,7 @@ class StockQuant(models.Model):
product_id = fields.Many2one(
'product.product', 'Product',
ondelete='restrict', readonly=True, required=True)
ondelete='restrict', readonly=True, required=True, index=True)
# so user can filter on template in webclient
product_tmpl_id = fields.Many2one(
'product.template', string='Product Template',
@@ -32,7 +32,7 @@ class StockQuant(models.Model):
string='Company', store=True, readonly=True)
location_id = fields.Many2one(
'stock.location', 'Location',
auto_join=True, ondelete='restrict', readonly=True, required=True)
auto_join=True, ondelete='restrict', readonly=True, required=True, index=True)
lot_id = fields.Many2one(
'stock.production.lot', 'Lot/Serial Number',
ondelete='restrict', readonly=True)