Public py function without DocType

I have to call a public py function, but i don’t have doctype in my app.
What file I put this function?

I think this is up to you, you can create a folder inside your app with a name of your choice like “core” or “utils” (with a __init__.py file inside) or simply add a file in your app.

I tried, but not worked calling by javascript method

method: "myapp.__init__.function_name",

You put the function inside __init__.py file? I need to see the file structure in order to help you.

You can have:

yourapp
    |-------yourapp
                 |------config
                 |------templates
                 |------www
                 |------(another default folders)
                 |------your_file.py (with your public function inside)

Them in yout .js you should call:
method: "yourapp.yourapp.your_file.function_name",

The

> __init__.py

files are required to make Python treat the directories as containing packages.
so if you want to call python function through ajax call

> method:your_app.your_custom_folder._your_pyfile.whitelisted_method

Tried the same thing, but not worked
Can you try this in your machine please?

frappe.ui.form.on("Purchase Invoice", "refresh", function(frm){
   frappe.call({
       method: "folder.folder.file.function_name",
       args: {
           doc_name: frm.doc.name,
       },
       callback: function(r) { console.log("worked!") }
   });
});

@Leonardo_Augusto considering above folder structure

frappe.ui.form.on("Purchase Invoice", "refresh", function(frm){
   frappe.call({
     method: "yourapp.your_file.function",
     args: {
      doc_name: frm.doc.name,
     },
    callback: function(r) { console.log("worked!") }
  });
})

Can I create a custom folder with a py file inside with a public function?

Like:
app/myapp/myapp/custom_folder/custom_file/funtion_name

@Leonardo_Augusto Yes you can create custom folder and put your .py file also.just add__init__.py file in that folder and your custom_file.py

In my app that’s worked, but in my friend’s app the file is not compiling…

@Leonardo_Augusto can u provide more detail how can i guess by this

In my app that’s worked, but in my friend’s app the file is not compiling…

Solved! I created another app…