Automate updating of price list

The price list only gets set when its initially not created ,
after a certain amount of time the prices of that price list increases -

so we just change the rate to the increased one in rate while selling the item because changing each ones price list individually is not feasible.

but it does not get saved with new in the price list like it does for adding it the first time .

How to make it so that the price list gets updated with the latest rate , which is entered while making the invoice.

Let me know if there is a normal way (settings) or will i have to code , if so how

Thanks in advvance

1 Like

@kt2152, go to item, then go to item price , change rate in pricelist and save.

That is the manual way , going to each item and changing ,

Perhaps i wasn’t clear ,
how can i set the latest rate defined in sales invoice to be saved to the price list rate of those items automatically.

Any help is appreciated .


1 Like

you can use custom script on validate or on_submit event, something like…{
				method: 'frappe.client.set_value',
				args: {

@jof2jc thanks,
Can you point me to the code where the item price list is created for the first time while saving?

I think i can figure something out from there.


1 Like

Is this possible to update from the sales order? For instance, when we are putting a product on the order, we will check to see the current price from supplier and input it at the time of the order. It would be great to have a checkbox or prompt to make this a permanent change on the price list. Any ideas?

Do this helps? This asks if you want to update price list, if different.

frappe.ui.form.on("Sales Invoice", "on_submit", function(frm) {
            $.each(cur_frm.doc.items || [], function(i, v) { // for each item on table do this
                var precoAntigo;
                    method: "frappe.client.get_list",
                    args: {
                        doctype: "Item Price",
                        filters: [
                            ['price_list', "=", cur_frm.doc.selling_price_list],
                            ["item_code", "=", v.item_code],
                        fields: [


                    callback: function(r) { // do this to found price list doc
                        precoAntigo = (r.message[0].price_list_rate);
                        var nomelista = r.message[0].name
                        // console.log(precoAntigo)
                        if (precoAntigo && precoAntigo != v.rate) {
                                `Deseja atualizar o preço do item ${v.item_name} de ${ precoAntigo } para ${ v.rate} na lista de preços ${cur_frm.doc.selling_price_list} ?`, //ask something to update price
                                function() { // do this if ok
                                    frappe.db.set_value("Item Price", nomelista, "price_list_rate", v.rate)
                                function() { // do nothing if cancel



can you help me please . how can i use this code ?

1 Like
  1. How can I use this script? and
  2. What happens to this kind of custom script when we have updated the system to the newest version?
    Using a script in V12 then update to V13 ErpNext & Frappe

@Paul could you found a way?

The script is a “Client Script” . Client Scripts (

The script “survives” the update, question is only if the used fields etc are still valid. Probably needs a case-by-case analysis.

Thank you for the reply.
Still I am searching a way to add Selling price automatically based on buying price, will try this if I couldn’t find a proper solution.

i edited this code and it worked perfect for me in v12 . but i still didn’t upgrade to v13 yet .

1 Like

how do you get the buying price into the system?

I am setting the buying price per item using Item Price

Then this is the point where to get started. Script to create additional item price, calculated based on the entered buying price.

Script is working great.

Can someone help me how to make the script check the currency of the price?
I want to store all prices in USD but sometimes the invoice is in different currency.
So I need the script to convert the price to USD and then update it in my price list.