Get Items by Group Hierarchy

Hello, ERPNext community,

I hope this message finds you well. I am currently working on a project and facing a challenge related to retrieving items based on their group hierarchy. I would appreciate any guidance or insights on whether there is an existing method within ERPNext to achieve this, or if I need to create a new method for the specific functionality.

To provide a clearer context, I have created a visual representation of the item group tree:

In this example, there is an item group named ‘Lakshmi Agency,’ which has a child group called ‘Pipes,’ and further, ‘PVC Valves’ as its sub-group. Now, if I have an item categorized under ‘PVC Valves,’ I would like to fetch all items under ‘Lakshmi Agency’ as well as items under its child groups (‘Pipes’ and ‘PVC Valves’).

Similarly, if I query for items under the ‘Pipes’ group, I would want to retrieve items under ‘Lakshmi Agency’ and its child groups (‘Pipes’ and ‘PVC Valves’).

If there is an existing method to accomplish this in ERPNext, I would be grateful for any information or examples.

Your assistance and insights are highly valued, and I appreciate any help in navigating through this requirement. Thank you in advance for your time and support.

Best regards,

Gopi Krishnan

@revant_one @netchampfaris @buildwithhussain @rmehta @umair

Hello, ERPNext community,

I wanted to provide an update on the challenge I was facing regarding retrieving items based on their group hierarchy. After spending some time exploring ERPNext, I found a solution that might be helpful to others facing a similar issue.

In the filter options, there are two key features called ‘descendants of’ and ‘ancestors of’ that can be utilized to fetch items based on their group relationships. If you have an item categorized under a specific subgroup, using ‘descendants of’ will retrieve all items under the current group and its child groups. Conversely, if you’re querying for items at a higher level, ‘ancestors of’ will fetch items from the parent group and its child groups.

I hope this information proves valuable to those encountering a similar requirement. Feel free to reach out if you have any questions or need further clarification.

Thank you to the ERPNext community for your support and insights.

Best regards,
Gopi Krishnan

2 Likes