changeset c64ccc6f426b in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset&node=c64ccc6f426b
description:
Add batch option to push queue tasks
issue11129
review381661002
diffstat:
invoice.py | 16 ++++++++++++----
sale.py | 7 +++++--
stock.py | 16 ++++++++++++----
3 files changed, 29 insertions(+), 10 deletions(-)
diffs (99 lines):
diff -r 84650f000d73 -r c64ccc6f426b invoice.py
--- a/invoice.py Mon Mar 07 00:52:58 2022 +0100
+++ b/invoice.py Wed Mar 09 00:57:17 2022 +0100
@@ -14,11 +14,15 @@
def wrapper(cls, invoices):
pool = Pool()
Sale = pool.get('sale.sale')
- with Transaction().set_context(_check_access=False):
+ transaction = Transaction()
+ context = transaction.context
+ with transaction.set_context(_check_access=False):
sales = set(s for i in cls.browse(invoices) for s in i.sales)
func(cls, invoices)
if sales:
- Sale.__queue__.process(sales)
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Sale.__queue__.process(sales)
return wrapper
@@ -145,10 +149,14 @@
def delete(cls, lines):
pool = Pool()
Sale = pool.get('sale.sale')
- with Transaction().set_context(_check_access=False):
+ transaction = Transaction()
+ context = transaction.context
+ with transaction.set_context(_check_access=False):
invoices = (l.invoice for l in cls.browse(lines)
if l.type == 'line' and l.invoice)
sales = set(s for i in invoices for s in i.sales)
super().delete(lines)
if sales:
- Sale.__queue__.process(sales)
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Sale.__queue__.process(sales)
diff -r 84650f000d73 -r c64ccc6f426b sale.py
--- a/sale.py Mon Mar 07 00:52:58 2022 +0100
+++ b/sale.py Wed Mar 09 00:57:17 2022 +0100
@@ -929,12 +929,15 @@
def confirm(cls, sales):
pool = Pool()
Configuration = pool.get('sale.configuration')
+ transaction = Transaction()
+ context = transaction.context
cls.set_sale_date(sales)
cls.store_cache(sales)
config = Configuration(1)
- with Transaction().set_context(
+ with transaction.set_context(
queue_name='sale',
- queue_scheduled_at=config.sale_process_after):
+ queue_scheduled_at=config.sale_process_after,
+ queue_batch=context.get('queue_batch', True)):
cls.__queue__.process(sales)
@classmethod
diff -r 84650f000d73 -r c64ccc6f426b stock.py
--- a/stock.py Mon Mar 07 00:52:58 2022 +0100
+++ b/stock.py Wed Mar 09 00:57:17 2022 +0100
@@ -17,12 +17,16 @@
def wrapper(cls, shipments):
pool = Pool()
Sale = pool.get('sale.sale')
- with Transaction().set_context(_check_access=False):
+ transaction = Transaction()
+ context = transaction.context
+ with transaction.set_context(_check_access=False):
sales = set(m.sale for s in cls.browse(shipments)
for m in getattr(s, moves_field) if m.sale)
func(cls, shipments)
if sales:
- Sale.__queue__.process(sales)
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Sale.__queue__.process(sales)
return wrapper
return _process_sale
@@ -91,11 +95,15 @@
def wrapper(cls, moves):
pool = Pool()
Sale = pool.get('sale.sale')
- with Transaction().set_context(_check_access=False):
+ transaction = Transaction()
+ context = transaction.context
+ with transaction.set_context(_check_access=False):
sales = set(m.sale for m in cls.browse(moves) if m.sale)
func(cls, moves)
if sales:
- Sale.__queue__.process(sales)
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Sale.__queue__.process(sales)
return wrapper