From 74a94f35a2b7e408c5cd3cd39032cc2f87d8c356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 30 Oct 2021 02:27:19 +0200 Subject: [PATCH] Limit size of grouping_filter ids The list of ids in grouping_filter are used inside an IN-clause so we must limit the size. issue10589 review379471002 --- sale.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sale.py b/sale.py index 8e4e92d146..32438cc086 100644 --- a/sale.py +++ b/sale.py @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. import datetime +from collections import defaultdict from trytond.i18n import gettext from trytond.pool import PoolMeta, Pool @@ -95,10 +96,12 @@ class Sale(metaclass=PoolMeta): with transaction.set_context(forecast=True, stock_date_start=date, stock_date_end=date): - pbl = Product.products_by_location( - [self.warehouse.id], - with_childs=True, - grouping_filter=(product_ids,)) + pbl = defaultdict(int) + for sub_product_ids in grouped_slice(product_ids): + pbl.update(Product.products_by_location( + [self.warehouse.id], + with_childs=True, + grouping_filter=(list(sub_product_ids),))) delta = {} for key, qty in pbl.items(): _, product_id = key