How can I read unsaved doctype in python method?

Hi Guys,
Is there a way to read unsaved doctype i mean
suppose we are creating an sales invoice which is not saved yet, and on entering customer i need to call an backend method for which doc is required but this case we can not read the unsaved doctype using get_doc or get_cached_doc.
I know we can use class to do it but i wanted to do it without overriding the doctype class.
This is there an solution or overriding the class and is the only option?

When you’re working on something like creating a sales invoice but haven’t saved it yet, you can’t directly fetch that unsaved data from the database. Instead, you have a few options:

  1. Client Script: If you need to do something based on what the user is entering, like choosing a customer, you can use JavaScript. It lets you get and use the information directly from the fields on the screen before saving.
  2. Server Scripts: For more complex tasks that need to happen before saving (before_save), you can write special scripts that run on the server. These scripts can do things like checking the customer’s details or running calculations. They’re designed to handle these jobs without needing to fetch unsaved data directly.

I hope this helps!

Yeah I know, but it is the complex task and needs to be performed in real time, so I cant use before_save as it triggers when user click save, and the logic will be complex for js. Anyway i am doing it using and doctype class method now. thanks for your reply.