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;
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Item Price",
filters: [
['price_list', "=", cur_frm.doc.selling_price_list],
["item_code", "=", v.item_code],
],
fields: [
"price_list_rate",
"name"
]
},
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) {
frappe.confirm(
`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
}
)
}
}
});
})
})
What happens to this kind of custom script when we have updated the system to the newest version?
Ex:
Using a script in V12 then update to V13 ErpNext & Frappe
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.
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.