1

I'm customizing an existing DocType(quotation) and I've added fields to the Quotation Item child table which affect the amount field of an Item. By default, i.e. before customizations, the grand_total, and Quotation net_totals get calculated as soon as an Item changes. But now that I have custom fields, how can I call the hypothetical "refresh" functions that do the default calculation?

Here is my current Custom Script that updates the Item amount on Quotation Item child table:

frappe.ui.form.on("Quotation Item", "paint", function(frm, doctype, name) {
  let row = locals[doctype][name];
  
  let rate = row.labour + row.trim + row.paint + row.spares;
  row.rate = rate;
  let total = rate * row.qty
  row.amount = total;
  refresh_field("items");
});
Chillar Anand
  • 27,936
  • 9
  • 119
  • 136
Redgren Grumbholdt
  • 1,115
  • 1
  • 19
  • 36

1 Answers1

0

There are few techniques to achieve your goal. The most effective one will depend on the HOOKS, specially :

  • doctype_js
  • override_doctype_class

As the first will allow you to run your js code along with the original doc js code. And the second will allow you to override the original doc class and will give you the capability to call the hypothetical method you override.

You can check the below links for more details: doctype_js override_doctype_class