Try ERPNext Buy Support Partners Foundation

[Managing multiple companies ]Filter Items in Sales Order Item table based on the company selected

Hello Team

I have created one custom field ‘Company’ wherever applicable to separate different companies I’m managing through one instance and then I apply user permission for company to restrict the access.

This custom field is also added in other DocTypes such as Item, Customers, Suppliers etc.

However, in the case of the users who have no such restrictions, there are some issues regarding which I need some help:

When I select the ‘Company A’ in the Sales Order, I expect the Items to get filtered based on it. (as the same custom field is there in the Item DocType too). But it lists out all the items in irrespective of the company previously selected.

Thanks & Regards
Satish

If i understood correctly. Below is the solution. Kindly give the “Default Company” in the Item Master (Item Defaults Table)

I have multiple companies .for that i want to add filter on item basis of company .

If you have different Item Master for each company means you have to do this.

I have only one item master with the same

Can you share any example?

Try it.

Yes, when i create a sales order in that select company & in that one table items in that item table i want to add filter and display the item on the bases of the company…


The above item filter by the company.this is i want…
This item comes in sales_order_item table.

For that i do this but it is not working

frappe.ui.form.on(‘Sales Order Item’, {
company:function(frm) {
frm.set_query(‘item_code’,function(){
return {
filters:{
‘company’:frm.doc.company
}
}
})
}
})

Can you please help me where to add this script?

Hi,
Try following code,

1 Like