Take FOREVER to save/submit a Sales Invoice when Perpetual Inventory is checked!

Here is what I am using:


When perpetual inventory is enabled, it takes me about a 97 seconds (over a minute) to save and submit a new Sales Invoice.

When Perpetual Inventory is NOT enabled it only takes 1.5 seconds

What is going one here?

I have a very fast VPS with 4gb memory and 4gb of swap and 4 vCPU. Everything else runs quite well on this system. Only creating Sales Invoices is taking forever.

Creating new Items only takes about 4 seconds
Creating new Users only takes about 3 seconds
Running complex reports is also quite fast

I checked the slow query log and there are NO entries related to this issue. This tells me there is possibly a looping problem in the scripts because the mysql slow query log only records lengthy times to run a backup and NOTHING related to sql transaction related to creating new Sales Invoices.

Any idea what might be happening here?

Has anyone else noticed this?


So, while I was digging into this I also asked a friend with experience in this to try to track down the source of the slowdown. Here is what I got back as an answer:

" The web server is being called a lot, even when doing basic things. The 2 calls I see the most are these:

** GET /api/method/frappe.desk.form.utils.validate_link*
** GET /api/method/frappe.desk.notifications.get_open_count*

*There are probably 20 +calls to validate_link when creating a new Sales Invoice? *

This is part of the performance issues, I think."

Does anyone else have this going on in their new systems?

Does anyone have a clue how this might be solved?


  1. login as administrator
  2. type url /app/recorder after your main domain or ip into browser address bar like below
  3. click start recording
  4. create and submit new sales invoice ,
  5. go back to /app/recorder to stop recording, check the recorded records.

Hi Miles,

Are you making a current dated invoice of a pre-dated invoice? Is Update Stock checked? Or is it just an accounting transaction?



The problem that your friend referring to is a serious frontend bottleneck but it only affects you while creating the invoice not after sending the form to the server for submission.

I am making a current date current time sales transaction with Update Stock enabled. This is something any normal immediate sales transaction would be.



Thanks for the tip!!

Not sure exactly how to read it yet, but at least I have a starting point. Thank you!


Ok, so I ran the recorder as suggested by @szufisher and here are the top 5 results that take up time in the process:

The process that takes the longest is:


This process is taking an unbelievable 118,664.83 ms to process!!!

Any idea what may be affecting this?


Just out of curiousity, what do you have for items in your invoice? Could you create an invoice for items which is non-stock. Is there a difference? Thanks

Hmm… Yes I think I can do the non-stock sale. The current sale was for a single item from inventory.

I have some training classes that are non stock I think that I can try this on. Will report back soon.


Wow, what a difference!!
Here is the top 5 tasks in the recorder list that take the most time for a “non-stock” sale. This was a sales invoice with a single item of no-stock type:

The difference it HUGE.

The total transaction was over in a few seconds as opposed to almost 2 minutes for the transaction with a single inventory item.

Why is this?


click /api/method/frappe.desk.form.save.savedocs it will drill down to details with queries executed.