Hello all
I’m trying to add a line item on a Quotation with custom code.
I manage to do so but the frappe.model.set_value() function seems to replace the description and rate.
Furthermore, it correctly triggers the calculation of both the amount and total, but it uses the standard selling rate rather than the rate provided by the custom code.
frappe.ui.form.on("Quotation", {
onload: function(frm) {
var g = frm.get_field('items').grid;
g.add_custom_button("Add Fee", function() {
var new_row = g.add_new_row();
var row_name = new_row.name;
frappe.model.set_value(g.doctype, row_name, "item_code", "item3");
frappe.model.set_value(g.doctype, row_name, "item_name", "Item 3");
frappe.model.set_value(g.doctype, row_name, "description", "Fee"); //Could be different per Quotation
frappe.model.set_value(g.doctype, row_name, "qty", 2);
frappe.model.set_value(g.doctype, row_name, "uom", "Nos");
frappe.model.set_value(g.doctype, row_name, "rate", 2.00);
frappe.model.set_value(g.doctype, row_name, "amount", 1.00);
frm.refresh_field("items");
});
}
});
How can I add a line item with custom code and still trigger the calculation of amount and total using the rate provided by the custom code?