changeset 6ed44b4db8d3 in modules/account_invoice:default
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=6ed44b4db8d3
description:
Add batch option to push queue tasks
issue11129
review381661002
diffstat:
account.py | 14 +++++++++++---
invoice.py | 12 ++++++++++--
2 files changed, 21 insertions(+), 5 deletions(-)
diffs (75 lines):
diff -r 26d1c350a774 -r 6ed44b4db8d3 account.py
--- a/account.py Sun Mar 06 18:22:06 2022 +0100
+++ b/account.py Wed Mar 09 00:57:16 2022 +0100
@@ -333,17 +333,25 @@
@classmethod
def create(cls, vlist):
Invoice = Pool().get('account.invoice')
+ transaction = Transaction()
+ context = transaction.context
reconciliations = super(Reconciliation, cls).create(vlist)
- Invoice.__queue__.process(list(_invoices_to_process(reconciliations)))
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Invoice.__queue__.process(
+ list(_invoices_to_process(reconciliations)))
return reconciliations
@classmethod
def delete(cls, reconciliations):
Invoice = Pool().get('account.invoice')
-
+ transaction = Transaction()
+ context = transaction.context
invoices_to_process = _invoices_to_process(reconciliations)
super(Reconciliation, cls).delete(reconciliations)
- Invoice.__queue__.process(list(invoices_to_process))
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ Invoice.__queue__.process(list(invoices_to_process))
class RenewFiscalYear(metaclass=PoolMeta):
diff -r 26d1c350a774 -r 6ed44b4db8d3 invoice.py
--- a/invoice.py Sun Mar 06 18:22:06 2022 +0100
+++ b/invoice.py Wed Mar 09 00:57:16 2022 +0100
@@ -1543,6 +1543,8 @@
def post_batch(cls, invoices):
pool = Pool()
Date = pool.get('ir.date')
+ transaction = Transaction()
+ context = transaction.context
cls.set_number(invoices)
for company, grouped_invoices in groupby(
invoices, key=lambda i: i.company):
@@ -1552,7 +1554,9 @@
if not invoice.payment_term_date:
invoice.payment_term_date = today
cls.save(invoices)
- with Transaction().set_context(_skip_warnings=True):
+ with transaction.set_context(
+ _skip_warnings=True,
+ queue_batch=context.get('queue_batch', True)):
cls.__queue__._post(invoices)
@classmethod
@@ -1587,6 +1591,8 @@
def _post(cls, invoices):
pool = Pool()
Move = pool.get('account.move')
+ transaction = Transaction()
+ context = transaction.context
cls.set_number(invoices)
moves = []
@@ -1611,7 +1617,9 @@
if to_print:
cls.__queue__.print_invoice(to_print)
if reconciled:
- cls.__queue__.process(reconciled)
+ with transaction.set_context(
+ queue_batch=context.get('queue_batch', True)):
+ cls.__queue__.process(reconciled)
@classmethod
def _check_similar(cls, invoices, type='in'):