[POS] Custom script in point of sale

Hello,

how could i create custom script in Point of sale? There is no hook created in this module or i can’t see it?

Refer following post:

Thanks for reply @kolate_sambhaji , but this is not that i am searching for. I need i custom script option for pos. I didn’t find that option in erpnext. Second solution is acording to that what i read is creating app(doctype). Creating app for one script is not what i wan’t. Third solution is to work in core what is not good. There is also missing hooks for pos.
Conclution: too complicated for one.js integration. If you know some other way that i did’t mention please let me know.

@vladucoju
This is the easy way to customise any page in frappe.

Custom Script are not available for pages.

This man ask for exaxly same thing

If this is true then erpnext has a big weakness…

How can i make that sales order load myfile.js without using custom script in backend, or to add buton without using backend options add custom script / add custom button?

@vladucoju

can you share any use case?

For above post, you can do export fixtures to save changes in custom fields, custom script in Customer or any standard doctype.

ERPNext is very good compare to other product. It is developed in such way that even end user also customise it without knowing any coding.
Do-It-Yourself Business Management System that will help you stay in control

Only documentation is not so good, that we can fix it anyway.

Thank you for your help. Erpnext is great. For end user is almost perfect. I am asking a questions for development. My use case is:
In POS page (view) i wan’t to add a custom buton which is in connection with my .js file. How to include my js file on this page. Example in picture below

@vladucoju
Please note Pages are different from Doctypes. POS is a page.
Doctype are configurable using custom script.
For pages you need to make separate app and add your js in hooks…

I have added new button “Add Customer”, I have also replaced existing popup and added field Vehicle No
All this we can to using javascript prototypes.

1 Like

If you add this with edithing core files than you did’t give the right answer. I don’t want to touch core. Update will oweridde my customization. I wan’t this to be clean. Could you give me example without editing core files?

I have added script in custom app.

I have already given example in How we can include js in particular page?

I do my js as you give example 10 days ago, and realized that it executes on all forms. Imagine you have another 30 new scripts executing in future. That is to much resource using.

It will not execute in all form. It will execute only in POS Page
Can you share your source code?

Sorry my mistake. All time I was inspecting main js file from my application because in that file I place console.log("…");.
Here below is part from my custom application hooks.py (“hello_world”):

-------------------------

include js, css files in header of desk.html

app_include_css = “/assets/hello_world/css/hello_world.min.css”
app_include_js = “/assets/hello_world/js/hello_world.min.js” # <= this loading confused my inspection

include js, css files in header of web template

web_include_css = “/assets/hello_world/css/hello_world.css”

web_include_js = “/assets/hello_world/js/hello_world.js”

include js in page

page_js = {“pos” : “public/js/file_from_hello_world.js”} # <= this loading is visible only inside POS page

--------------------------

Thanks @kolate_sambhaji . Need to go to solve another part of my problem. I will share complete manual later

1 Like

@vladucoju Thanks,
There is only lac of good documentation, so it will help other if you write How to add js on page once you done with your development.

Using javascript prototype you can override existing function in pos.

erpnext.pos.PointOfSale.prototype.make_offline_customer =  function (new_customer) {
 	var me = this;
 			console.log("hi in 22");
 }

If you want new function, then you can extend pos class in your js.
e.g.

erpnext.pos.PointOfSale = erpnext.pos.PointOfSale.extend({
	init: function (wrapper) {
		this._super(wrapper);
		var me = this;
		this.add_customer_sbkpos();
	},
	add_customer_sbkpos: function (wrapper) {
       console.log("in sbkpos");
	},
	
})
1 Like