0

I need to print sgst and cgst labels with their value on qweb.

The below code is printing amount untaxed, cgst, sgst, total value in the table. But I need to print only sgst and cgst labels and their value.

How can I do it in Odoo v15?

<tr style="border-bottom:hidden">
    <td style="width:80%;text-align:right;font-size:13px;">
        <t t-set="tax_totals" t-value="json.loads(doc.tax_totals_json)"/>
    </td>
    <td style="width:20%;text-align:right;font-size:13px;">
        <t t-call="account.document_tax_totals"/>
    </td>
</tr>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sakthi Priya
  • 209
  • 4
  • 19

1 Answers1

0

The tax_totals_json, is a field formatted in JSON as below

{
"amount_total": 4563.45, 
"amount_untaxed": 4342.2, 
"formatted_amount_total": "4,563.45 \u20ac", 
"formatted_amount_untaxed": "4,342.20 \u20ac", 
"groups_by_subtotal": 
{
    "Untaxed Amount": [
        {
        "tax_group_name": "Tax 15%", 
        "tax_group_amount": 221.25, 
        "tax_group_base_amount": 1475.0, 
        "formatted_tax_group_amount": "221.25 \u20ac", 
        "formatted_tax_group_base_amount": "1,475.00 \u20ac", 
        "tax_group_id": 2, 
        "group_key": "Untaxed Amount-2"}
        ]
    }, 
        "subtotals": 
        [
            {
            "name": "Untaxed Amount", "amount": 4342.2, 
            "formatted_amount": "4,342.20 \u20ac"
            }
        ], 
            "allow_tax_edition": false}

So for example if you would like to access to the Taxes value, your code will be as below:

<t t-set="tax_totals" t-value="json.loads(doc.tax_totals_json)"/>
<t t-foreach="tax_totals['subtotals']" t-as="subtotal">
    <t t-set="subtotal_to_show" t-value="subtotal['name']"/>
    <t t-foreach="tax_totals['groups_by_subtotal'][subtotal_to_show]" t-as="amount_by_group">
        <t t-if="len(tax_totals['groups_by_subtotal'][subtotal_to_show]) > 1">
            <span class="text-right" t-esc="amount_by_group['formatted_tax_group_amount']"/>
        </t>
        <t t-else="">
            <span class="text-right" t-esc="amount_by_group['formatted_tax_group_amount']" />
        </t>
    </t>
</t>