[PERF] mrp,stock,purchase: sql improvement
First correction: replace call to `read_group` to `_read_group` in order to avoid useless joints on table product_template and ir_translation when the grouping key is a Many2One. Second correction: add an index on workorder's `state` field. The get_conflicted_workorder_ids() method search for ready workorders that are in conflict relate to their planning. The state value is searched to many times to not index it closes odoo/odoo#106582 Task: 2852423 X-original-commit: b5019eec76845316e554f2dd11a6d8bbf6fea433 Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com> Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
@@ -63,7 +63,7 @@ class MrpWorkorder(models.Model):
|
||||
('done', 'Finished'),
|
||||
('cancel', 'Cancelled')], string='Status',
|
||||
compute='_compute_state', store=True,
|
||||
default='pending', copy=False, readonly=True, recursive=True)
|
||||
default='pending', copy=False, readonly=True, recursive=True, index=True)
|
||||
leave_id = fields.Many2one(
|
||||
'resource.calendar.leaves',
|
||||
help='Slot into workcenter calendar once planned',
|
||||
|
||||
@@ -33,7 +33,7 @@ class ProductProduct(models.Model):
|
||||
|
||||
qty_by_product_location, qty_by_product_wh = super()._get_quantity_in_progress(location_ids, warehouse_ids)
|
||||
domain = self._get_lines_domain(location_ids, warehouse_ids)
|
||||
groups = self.env['purchase.order.line'].read_group(domain,
|
||||
groups = self.env['purchase.order.line']._read_group(domain,
|
||||
['product_id', 'product_qty', 'order_id', 'product_uom', 'orderpoint_id'],
|
||||
['order_id', 'product_id', 'product_uom', 'orderpoint_id'], lazy=False)
|
||||
for group in groups:
|
||||
|
||||
Reference in New Issue
Block a user