Posting too many invoices is incredibly slow


We are doing tests on invoicing. We have 219 validated invoices in February. We have activated the trytond-worker.

If we select the whole 219 invoices and we do a post on it, it’s very slow. (sometimes we have a warning : “The invoice … generates a payment date … in the past”) Between 2 warnings, there’s approximately 1 minute ! (and warning concerns 2 consecutive invoices (we check invoice numbers displayed in the warning).

If we select a block of 20 invoices, time to post is approximately 1 minute (which is correct).

So, wondering why it takes so much time when selecting all the invoices ? (something wrong with the process to check numbering?) Problem with the worker ?

Could you test on your side ? Thanks.

I think its relevant to share the number of lines that it has each invoice. From my experience its not the same to post 219 invoices with 1 line, than posting 219 invoices with 30-40 lines each. The latter will be slower.

Could you share such detail so others can test also?

Indeed, our invoices have maximum 3 lines. Most of them have 1 line.

When a warning is raised, the all request is roll-backed so if you skip the warning the server has to restart the work from beginning.

This means that it takes 1 minute to reach the warning which seems strange because the only operations before that are setting employee (a single write) and grouping by company (a single read).

So I would suspect that the validation after the write of employee is slow.
It will be interesting to see where time is spent.

I’ll retry on a local machine without worker to trace the process

I do not think there are any process are done by workers when posting an invoice.

Workers are most used to generate the invoice reports and convert them to pdf.

Also, I can’t trace when using worker.

But this does not block the main request. The invoices are posted in the queue.

But maybe In case queue_batch is True, not use the configuration queue of batch_size and count is 1 (#13133) · Issues · Tryton / Tryton · GitLab is the problem.