diff --git a/account.py b/account.py index b5f2a43d35..80e0ad13ac 100644 --- a/account.py +++ b/account.py @@ -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): diff --git a/invoice.py b/invoice.py index 15c866fdf9..f76749ef3d 100644 --- a/invoice.py +++ b/invoice.py @@ -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'):