Try ERPNext Buy Support Partners Foundation

How to Update Quotation Item 'Amount' Value When a Checkbox is Clicked?

Hello everyone, I have a quick question.
I’m developing a custom script to update the ‘Amount’ field in Quotation Item (child table) box to be 0 (zero) when a checkbox is clicked but I tried to do it with a checkbox and a select field and still nothing seems to affect the amount field.

  • Business Case: the client wants to add alternative items in their quotation while subtracting/excluding their rate from the total quotation amount so in order to do that we thought we would make the item amount zero while leaving the rate as is so we can display it still in the quotation.
  • Scenario I’m looking for:
  1. Create New Quotation
  2. Add New Item
  3. Click on Checkbox ‘is Alternative Item?’
  4. Item ‘Amount (base currency)’ field value changed to zero by this simple equation.
    *equation: item quantity * item rate * 0

Script I’m trying to achieve this with.

frappe.ui.form.on("Quotation Item", {
is_alternative_item: function(frm){
var row = locals[cdt][cdn];
if(frm.doc.is_alternative_item==1){
        row.base_amount = flt(row.qty) * flt(row.rate) * 0;
        frappe.model.set_value(cdt, cdn, 'base_amount', flt(row.qty) * flt(row.rate) * 0);
        refresh_field("items");
    }
},
});