Customize sales invoice printing format

I have product bundles defined and we usually sell the product bundle. However, when printing the sales invoice, I want to print all the items that are in the product bundle with item rate, quantity and the name.

For example a bundle is created ‘Bundle-Polo t-shirts’ Rs. 6000
And the items included in the bundle are,

  1. Polo t-shirt - red - Medium 10 qty @ Rs.300.00
  2. Polo t-shirt - red - Large 10 qty @ Rs.300.00

I create a sales order to sell 2 bundles and the total of the sales invoice will be Rs.12,000. By default, following will be shown in the printed sales invoice.

Instead of printing above I want to print actual items with their correct name, qty and rate in the sales invoice. For example,

Can someone suggest a way to achieve this?

You can try doing something like this:

Thanks @KanchanChauhan!

Unfortunately that doesn’t work.

Can I run a SQL query in print formats so I can get the details populated?

Other option is to create a custom module where that populates a new table with all the information I need when saving sales invoice. I an new to ERPNext development so not sure how complex that will be.

Any suggestions?

How can we do it?