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
get_pricing_rule_for_item,
set_transaction_type,
)
from erpnext.setup.doctype.brand.brand import get_brand_defaults
from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
from erpnext.setup.utils import get_exchange_rate
from erpnext.stock.doctype.batch.batch import get_batch_no
from erpnext.stock.doctype.item.item import get_item_defaults, get_uom_conv_factor
from erpnext.stock.doctype.item_manufacturer.item_manufacturer import get_item_manufacturer_part_no
from erpnext.stock.doctype.price_list.price_list import get_price_list_details
sales_doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice", "POS Invoice"]
purchase_doctypes = [
"Material Request",
"Supplier Quotation",
"Purchase Order",
"Purchase Receipt",
"Purchase Invoice",
]
This file has been truncated. show original