From 9399f9f2cf08041d2aff2a17c1bf9f020d389730 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 --- account.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/account.py b/account.py index c0bae5f644..efbac86f17 100644 --- a/account.py +++ b/account.py @@ -2,6 +2,7 @@ # this repository contains the full copyright notices and license terms. from trytond.model import ModelView, Workflow from trytond.pool import Pool, PoolMeta +from trytond.transaction import Transaction class Invoice(metaclass=PoolMeta): @@ -13,11 +14,15 @@ class Invoice(metaclass=PoolMeta): def post(cls, invoices): pool = Pool() Move = pool.get('stock.move') + transaction = Transaction() + context = transaction.context super().post(invoices) moves = sum( (l.stock_component_moves for i in invoices for l in i.lines), []) if moves: - Move.__queue__.update_unit_price(moves) + with transaction.set_context( + queue_batch=context.get('queue_batch', True)): + Move.__queue__.update_unit_price(moves) class InvoiceLine(metaclass=PoolMeta):