Hi
I’m on version v10.0.17 and added a custom field on the sales order item doc type.
I have written a custom script that tries to alter the way that the system calculates line total.
By default, the line total is calculated as Qty * Rate.
I would like the line total to be calculated as follows:line total= new_custom * rate.
I have accomplished this successfully using the script below but the changes are discarded when the document is saved to draft.
frappe.ui.form.on(“Sales Order Item”, “new_custom_field”, function(frm, doctype, name) {
var row = locals[doctype][name];
@max_morais_dmm After giving your response much thought, I have made sense of what you are saying.
I have managed to reset the both the qty and rate field to come back to the result I was after by the initial rate * custom field.
I’ve had to add more custom fields to keep the original values in the qty and rate so that these can be displayed to the customer.
In the back end however, to keep things simple, I reset the original qty and rate which I just hide when printing documents.