Sorting Materials Required (Exploded)

Hi Guys,

I’ve been using the ERPNEXT for the last 2 and half months. I’m not the expert in programming, still learning. It’s a great software by the way.
I’ve been doing a working experience for one company. But I’m struggling a little bit with one task that my boss has assigned me. It may be sound silly for some people that’s been in the industry a little longer, but I couldn’t figure it out how to solve this problem by myself.

He had asked me to sort the Materials Required (Exploded) by Item Code in the BOM. He wants to look a little bit more clear, because depend of the sub-assimblies it is very messy and the items doesn’t display on order.
Like the image below.

I also tried to find where it gets the database and sort it, but I didn’t find as well.
I’ve tried from the DOCTYPE BOM Explosion Item to sort that from the field as the pic. But it didn’t work.

I don’t know if it’s clear what I want to do, but if someone can help I would really appreciate.

Thanks.
Alex

Makes sense to me.

Also sometimes you want to sort instead by item number ( typically the bubble number on the assembly drawing if you have one), even by the quantity perhaps to see what the total quantities involved are.

Sorry I don’t know enough to help with a solution though.

Dale

You will have to know a bit of python though.

Sort the list before this:

Hi guys,

Finally I figured it out how to sort the Material Required (Exploded).

In my case I wanted to sort the list by item_code, so in the for loop I added the sort function as the code below.

    ...
    self.set('flat_bom_details', [])        
    for d in sorted(self.cur_exploded_items, key=itemgetter(0)):
          ch = self.append('flat_bom_details', {})
    ...

I hope it can help someone else.

Thanks
Guys

Nice, now send a pull-request :smile: