Both of them create gl entry submit and preview

For these types of tasks, there are many solutions depending on the scenario and the way you want to approach them.

  • Check whether the request path is different using frappe.local.request.path for both requests?

or

  • You can set flags (frappe.flags.gl_preview = true) and check in your code if frappe.flags.gl_preview is true, but for this, you will have to override the stock_controller.py code or other ERPNext file code.