changeset 157b5f9e2545 in modules/account_invoice_stock:default
details: 
https://hg.tryton.org/modules/account_invoice_stock?cmd=changeset&node=157b5f9e2545
description:
        Add batch option to push queue tasks

        issue11129
        review381661002
diffstat:

 account.py |  12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diffs (36 lines):

diff -r 1ca16b848c7a -r 157b5f9e2545 account.py
--- a/account.py        Sat Dec 18 16:29:39 2021 +0100
+++ b/account.py        Wed Mar 09 00:57:17 2022 +0100
@@ -13,10 +13,14 @@
     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 @@
     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):

Reply via email to