Make rate column as mandatory in Purchase order item table

I need the rate column must be filled and not be null.

How to achieve this?By code or Changes in setting…?

You can extend the validation of the record with a custom script on the Purchase Order. Something like this:

frappe.ui.form.on('Purchase Order', {
    validate: function(frm) {
        // check if each item has a rate != 0
        var items = cur_frm.doc.items;
        var rates_ok = true;
        items.forEach(function(entry) {
            if (entry.rate == 0) {
                rates_ok  = false;
            }
        });
        if (!rates_ok)) {
            frappe.msgprint( __("Please set valid rates"), __("Validation") );
            frappe.validated=false;
        }
    }
});

Hope this helps.

This doesn’t work ,I want the Rate column should be filled before submitting on Purchase order Item table.

@mark4u

  1. Open doctype list and select purchase order item

  2. select rate and check as mandatory field.

If it work mark as solution.

I already made Mandatory but ,Doesn’t works