Suppress printing of sales order items based on item_group

I want to suppress the printing of some sales order items on the Sales Order Print Format based on their item_group. This will stop the printing of some “Services” group items that I don’t want to show to the customer on this print format.

Can anyone help me with the logic to do this? I don’t even want spaces, etc I need to actually prevent the print format from adding the rows to the table where these items exist.

This is what currently prints - my main item plus 3 Services items:

And I want to suppress the 3 items whose item_group=‘Services’ - ie BCART, FWLIME and FWPLUS5 so it would look like:

My table code is:

<table class="table table-condensed table-hover table-bordered">
    <tr>
        <th>Sr</th>
        <th>Description</th>
        <th class="text-right">Quantity</th>
        <th class="text-right">Size</th>
        <th class="text-right">Colour(s)</th>
    </tr>
    {%- for row in doc.sales_order_details -%}
    <tr>
        <td style="width: 3%;">{{ row.idx }}</td>
        <td style="width: 42%;"><b>{{ row.item_code or '' }} </b><br>{{ row.item_name or '' }}</td>
        <td style="width: 25%; text-align: right;">{{ row.qty or '' }}</td>
        <td style="width: 15%; text-align: right;">{{ row.size or '' }}
        <td style="width: 15%; text-align: right;">{{ row.print_process or '' }}</td>
    </tr>
    {%- endfor -%}
</tbody>

Thanks
Liam.

Try this

{%- for row in doc.sales_order_details -%}
    {% if frappe.db.get_value("Item", row.item_code, "item_group") != 'Services' %}
        <tr>
            <td style="width: 3%;">{{ row.idx }}</td>
            <td style="width: 42%;"><b>{{ row.item_code or '' }} </b><br>{{ row.item_name or '' }}</td>
            <td style="width: 25%; text-align: right;">{{ row.qty or '' }}</td>
            <td style="width: 15%; text-align: right;">{{ row.size or '' }}
            <td style="width: 15%; text-align: right;">{{ row.print_process or '' }}</td>
        </tr>
    {% endif %}
{%- endfor -%}

Hi @BhupeshGupta

That suppresses line 2 but lines 3 and 4 still show:

Edit: Nevermind, the item_group on the others is not Services, it’s Shipping. Can I do an inlist as part of that code you gave me please?

Thanks
Liam.

I have not tried it myself. You can

One more thing

I forgot to change the serial no. Currently it is driven by idx. change it to loop index.

change

<td style="width: 3%;">{{ row.idx }}</td>

to

<td style="width: 3%;">{{ loop.index }}</td>

Where do you customize the code for the table?

@gio-avk the code for printing the table exists in the Print Format under Setup.