[SOLVED] Price Rate in purchase with different UOM

Hi all,

in Purchase Order adding an Item will get price per UOM and display in Rate column.

Changing the UOM, let’s say to BOX with UOM conversion factor = 12 it changes the Qty as per Stock UOM, but not the Price List Rate (it remain the one applied for UOM with conversion factor = 1)

not sure if it’s a bug or if it is by design

Hi all,

can’t get to work the following:

frappe.ui.form.on("Purchase Order Item", "uom", function(frm,doctype,name) {
 var row = locals[doctype][name];
 row.rate = flt(row.conversion_factor * row.price_list_rate * (1 - row.discount_percentage / 100.0));
 row.amount = flt(row.rate * row.qty)
 refresh_field("items");
});

basically row.conversion_factor isn’t refreshed on uom change and before it’s used, any help?

I finally managed to have it working adding a timeout to allow conversion_factor to refresh, code:

frappe.ui.form.on("Purchase Order Item", "uom", function (frm, doctype, name) { 
    setTimeout(function () {
        var row = locals[doctype][name];
        row.rate = flt(row.conversion_factor * row.price_list_rate * (1 - row.discount_percentage / 100.0));
        frappe.model.set_value(doctype, name, "amount", flt(row.rate * row.qty));
        refresh_field("items");
    }, 300);
});
4 Likes