Duplicate the data suddenly in sales invoice

Hello every one
I have customizations in sales Invoice like

  • client script for doing some calculations in taxes table based on some functions write them in a specific file in my custom app this script fired when a particular field has data. and
  • server script for some validation but I disabled it. and
  • API for creating sales Invoice directly from another system.
    The issue is that:
    When I create a new sales Invoice and then save it the script works and everything works well but after that when refresh the doc every row in items and taxes is duplicated once and when I refreshed again no nothing happened Still the first duplicate


You can investigate what going on with
to check detail method call done by Frappe/ERPNext at the call of API end point.

I think there are cores methods (that may be be overrided, if core method are whitelisted) by hook into your custom app to avoid duplicate entry, instead of add Taxes rows in your custom app script.

i follow this

check all
then i stoped after save and refresh the doc
i get this

i open the save one

i filter the insert just

i found these