ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Has Custom Page events?


#1

How can I run a script on POS Webview event? Like submit or add items to shopping chart?


#2

POS is not a webview but a custom page. And there are no custom events for pages right now.


#3

So it’s not possible hit an API selling products by POS event??
My logic is: when submit a POS using event “on_submit”, hit my ecommerce API updating the stock


#4

Any hint?


#5

please look at this :


#6

I did not understood, just need to run js on a event like:

frappe.ui.form.on("point-of-sale", "refresh", function(){
    console.log("worked");
});

#7

It is not working like that, what you do is working just for “doctype” not “page”


#8

Uhum, I understood that. So, can you give me an example how to run a console log on on_load event in a page?


#9

Guys, I’m still stuck on that, if you can show us a example I’ll be grateful.


#10

Found it!

Created a js file in public/js app folder, following script:

frappe.pages['pos'].refresh = function (wrapper) {
   console.log('worked!');
}

Then you have to appoint the js file in hooks.py under "#include js in page" row, like this:

#include js in page
page_js: {"pos" : "public/js/js_file.js"}

Note: as far I know, you cannot do it on custom_script feature site, cause ‘pos’ it’s a page, not a doctype. So, you can do it just using a app.


#11

Great solution.
Do you know how to do the same in the List (desk#List)?
But not for a spesific list. It is for generic List.
For example for the toolbar in the listview

Thank you