[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:
William Henrotin
2022-11-25 18:56:02 +01:00
parent e23f0e1125
commit 9ee9be3f4d
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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',
+1 -1
View File
@@ -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: