From 4acdcc7efe9d2a0f249176d02b99c1667667f902 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Mar 2022 00:57:17 +0100 Subject: [PATCH] Add batch option to push queue tasks issue11129 review381661002 --- production.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/production.py b/production.py index 3fa9d740c1..9102c3d1e3 100644 --- a/production.py +++ b/production.py @@ -16,9 +16,11 @@ def process_sale_supply(func): def wrapper(cls, productions): pool = Pool() Sale = pool.get('sale.sale') + transaction = Transaction() + context = transaction.context sales = set() - with Transaction().set_context(_check_access=False): + with transaction.set_context(_check_access=False): for sub_productions in grouped_slice(productions): ids = [p.id for p in sub_productions] sales.update([s.id for s in Sale.search([ @@ -26,7 +28,9 @@ def process_sale_supply(func): ])]) func(cls, productions) if sales: - Sale.__queue__.process(sales) + with transaction.set_context( + queue_batch=context.get('queue_batch', True)): + Sale.__queue__.process(sales) return wrapper