Problem whit the filed rate

I need chand the value whit the new

frappe.ui.form.on(“Sales Order Item”, “item_code”, function(frm, cdt, cdn) {
var q=locals[cdt][cdn];
if(q.item_code != null){
frappe.model.set_value(cdt, cdn, “rate”, value);
refresh_field(“items”);
}
});

for example i need the filed “rate” chenge the value default but when i change whit this code, this value retorn the value default

Hi @Christian_Sanchez

You can not change the value of existing fields(like rate, amount) using customizations because system will restore the default value. Use better way to make this task like create separate form or extend the code into your custom app and make changes there

hi @rohit_w
but when i save these they change again (amount and total)

my code

erpnext.buying.PurchaseOrderItem = erpnext.buying.BuyingController.extend({
item_code: function(frm, cdt, cdn){
var d = locals[cdt][cdn];
if (d.item_code) {
return frappe.call({
method: “nodux_sales_invoice.purchase_order.get_item_code_sale”,
args: {
item_code : d.item_code
},
callback: function(r) {
if(r.message) {
var d = locals[cdt][cdn];
$.each(r.message, function(k, v) {
d[k] = v;
});
// alert(“ennn”);
calculate_total(frm);
refresh_field(“items”);
frm.refresh_fields();
}
}
});
// frm.refresh_fields();
}

  },

)};

Hi @Christian_Sanchez

System restore the default data on save from the server side