From 8ca029e3aecfc971f15f909febde1e2bbd22df1c 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/account.py b/account.py index 04d1264876..e8ca336cdb 100644 --- a/account.py +++ b/account.py @@ -13,10 +13,14 @@ 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_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 InvoiceLineStockMove(ModelSQL): @@ -102,11 +106,15 @@ class InvoiceLine(metaclass=PoolMeta): def write(cls, *args): pool = Pool() Move = pool.get('stock.move') + transaction = Transaction() + context = transaction.context super().write(*args) lines = sum(args[0:None:2], []) moves = sum((l.stock_moves for l in 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) @classmethod def copy(cls, lines, default=None):