Sort child table on print format

HI there-
We have a need to have our items sorted on our CUSTOM PRINT FORMAT for sales order in order of Item number or default supplier. Either one will work but default supplier does NOT show up on the sales order/invoice but is in the child table - just not the print format.

Anyways, does anyone have some custom way I can apply this to the custom print format for the child table sales order item?

Thanks!
Heather

If you can share your custom print format code here, maybe someone might be able to help.

I just realized that I meant it’s not a standard report. I am on ERPNext Cloud so I can only customize the print format with the drag and drop builder and then I am forced to rename it. Essentially, I want to sort the items in my sales order item table by item_code. I was hoping to just insert custom HTML on the print format screen above the Items (table) section and have it sort on the print out. Sound feasible?

This link may help you

Hi @charlie-cook I recently had similar requirement of sorting in print format.

I Created a custom print format similar to suggested by @Pawan (Say Standard Yes or else it wont show in commits).

And then I used sort() feature of for loop in Jinja templates.

A code snippet similar to what I uses is here:

{% for item in doc.items|sort(attribute='itemno') %}
    ...
{% endfor %}

where items is the list of items which is there in current doc type for which you are creating the custom doc type.

Hope this helps.

Regards,

Parth

4 Likes

Thanks so much! I was able to get it squared away. Appreciate the help!