Hi,
I am trying to change the set_query in purchase orders for item_code
in items
table, basically I am trying to make the logic for sub-contracted items without having the need for BOM.
I have created a non-stock item and I have add a custom field for item_code2 and a warehouse, so when we are making a PO the system would automatically make a Transfer entry for the item_code2 from warehouse to sub_contracting warehouse without there being a need for creating a BOM.
Since creating a BOM is kind of out of our context of manufacturing.
Now for this I have created a new_field in PO which is a check field is_subcontracting
now I want to show the users items which are marked as is_sub_contracted
in the list of items but due to code below:
I unable to show sub_contracted items in the item list. I would like to know if I somehow I could override the set_query
I have added the below code in my purchase order client script:
cur_frm.cscript.is_subcontracting = function(doc, cdt, cdn) {
cur_frm.set_query("item_code", "items", function(){
if (cur_frm.doc.is_subcontracting == 1){
return{
query: "erpnext.controllers.queries.item_query",
filters:{ 'is_sub_contracted_item': 1 }
}
}
});
};