[FIX] mrp_subcontracting: sql crach

In large database, if you try to get all subcontrat quant you can crach postgres with a big query.

closes odoo/odoo#106543

X-original-commit: aa104980d483efef087198dc5bb70ec63a47ed7e
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Florent de Labarre
2022-11-25 17:56:57 +01:00
committed by GitHub
parent a3e1975074
commit 38ff430f20
@@ -14,13 +14,4 @@ class StockQuant(models.Model):
if operator not in ['=', '!='] or not isinstance(value, bool):
raise UserError(_('Operation not supported'))
subcontract_locations = self.env['stock.location'].search([('is_subcontracting_location', '=', 'True')])
quant_ids = self.env['stock.quant'].search([
('location_id', 'in', subcontract_locations.ids),
]).ids
if (operator == '!=' and value is True) or (operator == '=' and value is False):
domain_operator = 'not in'
else:
domain_operator = 'in'
return [('id', domain_operator, quant_ids)]
return [('location_id.is_subcontracting_location', operator, value)]