Limit the quotation item selection ( custom script)

Hi Guys,

I need to limit the item to be created in the quotation.
E.G the user only able to select the L00001 from the list quotation item list.

I think i need to write the custom script but i the script i wrote is not work. Can someone help on this?

@kenny
if you want display some item .You can perform this by using get_query().

@jsukrut,

thanks for the reply.

but the get_query needed to be declared in ‘quotation item’ doctype or ‘quotation’ doctype?

and is the coding below correct?

frappe.ui.form.on(“Item”, “onload”, function(frm) {
cur_frm.get_query(“item”, function(){
return {
“filters”: [
[“Item”: “item_code”, “=”, “L00001”]
]
}
});
});

appreciate your help y.

Change the DocType from Quotation Item to Quotation then try this:

frappe.ui.form.on("Quotation", "onload_post_render", function(frm) {
    frm.fields_dict.items.grid.get_field("item_code").get_query = function() {
        return {
            filters: {
                "item_code": "L00001"
            }
        }
    }
});
1 Like

thanks @mibrahim. It works!. can ask one more question? how i add or in the filter?
filters: {
“item_code”: “L00001” || “L00002”
}

is this correct?

@kenny

try this

filters: [
		["Item", "item_code", "in", ["L00001","L00002"]],
	]
OR

filters: {"name": ["in", ["L00001","L00002"]] }
2 Likes

@Sangram thanks. it work nicely