Tuesday, 20 February 2018

how to group the same item in any invoice using jinja templating .

<div class="container-fluid">
<div class="row">
<table class="table table-bordered">
 <tr>
    <th style="text-align: center;">Sr. No.</th>
    <th style="text-align: center;">Item Code</th>
    <th style="text-align: center;">Description</th>
    <th style="text-align: center;">Quantity</th>
    <th style="text-align: center;">For Warehouse</th>
    <th style="text-align: center;">UOM</th>
    <th style="text-align: center;">Project</th>
   
   
  </tr>
  {% for group in doc.items|groupby('item_code') %}
  <tr>
      <td style="width: 3%;">
          {{ group.list[0].idx or ''}}
      </td>
      <td style="width: 5%;">
          {{ group.grouper or ''}}
      </td>
      <td style="width: 21%;">
          {{ group.list[0].description or ''}} 
      </td>
      <td style="width: 7%;">
      {{ group.list|sum(attribute='qty') or ''}}
         
      </td>
      <td style="width: 14%;">
          {{ group.list[0].warehouse or ''}}
      </td>
      <td style="width: 14%;">
          {{ group.list[0].uom or ''}}
      </td> 
      <td style="width: 14%;">
          {{ group.list[0].item_group or ''}}
      </td> 
  </tr>
  {%- endfor -%}
 
  </table>
</div>
</div>

No comments:

Post a Comment

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...