Add batch option to push queue tasks

issue11129
review381661002
This commit is contained in:
Cédric Krier committed 2022-03-09 00:57:16 +01:00
1 parent 690327b77c
commit 3fe0a90e64
2 files changed
+21 -5

No files matched your search

+11 -3
View File
@@ -333,17 +333,25 @@ class Reconciliation(metaclass=PoolMeta):
@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):
+10 -2
View File
@@ -1543,6 +1543,8 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin):
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'):