1
votes

When I added a for loop on the tr tag in qweb Odoo 12 report, the report is going blank. I don't know why.

The error portion of the code is,

                            <tr>
                                <tr t-foreach="o.order_line" t-as="l">
                                    <td style="text-align:left;" colspan="2">
                                        Untaxed Amount
                                        <br/>
                                        Taxes
                                        <br/>
                                        Total
                                    </td>
                                    <td style="text-align:center;">
                                        <span t-if="o.amount_untaxed"
                                              t-field="o.amount_untaxed"/>
                                        <br/>
                                        <span t-if="o.amount_tax"
                                              t-field="o.amount_tax"/>
                                        <br/>
                                        <span t-if="o.amount_total"
                                              t-field="o.amount_total"/>
                                    </td>
                                    <td style="text-align:right;">
                                        المجموع قبل الضرائب
                                        <br/>
                                        الضرائب
                                        <br/>
                                        المجموع النهائي
                                    </td>
                                    <td style="text-align:left;">
                                        Item
                                        <br/>
                                        Description
                                        <br/>
                                        Quantity
                                    </td>
                                    <td style="text-align:center;">
                                        <span t-if="l.product_id.name"
                                              t-field="l.product_id.name"/>
                                        <br/>
                                        <span t-if="l.name"
                                              t-field="l.name"/>
                                        <br/>
                                        <span t-if="l.product_uom_qty"
                                              t-field="l.product_uom_qty"/>
                                    </td>
                                    <td style="text-align:right;">
                                        الصنف
                                        <br/>
                                        الوصف
                                        <br/>
                                        العدد
                                    </td>
                                </tr>
                            </tr>

If needed the entire code of this report is below,

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <template id="report_airway_bill">
        <t t-call="web.basic_layout">
            <t t-foreach="docs" t-as="o">
                <div class="page">
                    <div class="row">
                        <table id="1" width="100%" class="table table-condensed"
                               style="border:1px solid black;border-collapse: collapse;">
                            <tr>
                                <th width="33%" style="align:left;">
                                    <div class="row" align="left">
                                        <div class="col-3">
                                            <img t-if="o.company_id.logo"
                                                 t-att-src="'data:image/png;base64,%s' % o.company_id.logo"
                                                 height="100%" width="100%"/>
                                        </div>
                                    </div>
                                </th>
                                <th>

                                </th>
                                <th width="33%" style="align:right;">
                                    <div class="row" align="left">
                                        <div class="col-3">
                                            <img t-if="o.company_id.logo"
                                                 t-att-src="'data:image/png;base64,%s' % o.company_id.logo"
                                                 height="100%" width="100%"/>
                                        </div>
                                    </div>
                                </th>
                            </tr>
                        </table>

                        <table id="2" width="100%"
                               style="border-collapse: collapse;border:1px solid black;">
                            <tr>
                                <tr style="border:1px solid black;border-collapse: collapse;">
                                    <td style="text-align:left;border:1px solid black;border-collapse: collapse;">
                                        طريقة الدفع
                                        <br/>
                                        Type Of Payment
                                    </td>
                                    <td style="border:1px solid black;border-collapse: collapse;">
                                        x
                                        <br/>
                                        y
                                    </td>
                                    <td style="text-align:right;border:1px solid black;border-collapse: collapse;">
                                        COD عند الاستلام
                                        <br/>
                                        Cash عند الارسال
                                    </td>
                                    <td style="text-align:left;border:1px solid black;border-collapse: collapse;">
                                        From :
                                        <span t-if="o.partner_id.name"
                                              t-field="o.partner_id.name"/>
                                        <br/>
                                        Dest :
                                        <span t-if="o.x_studio_field_WJ3co.name"
                                              t-field="o.x_studio_field_WJ3co.name"/>
                                    </td>
                                    <td style="text-align:left;">
                                        Bill Number:
                                    </td>
                                    <td style="text-align:center;">
                                        <strong>
                                            <span t-if="o.x_studio_tracking_number"
                                                  t-field="o.x_studio_tracking_number"/>
                                        </strong>
                                    </td>
                                    <td style="text-align:right;">
                                        :رقم البوليصة
                                    </td>
                                </tr>
                            </tr>
                            <tr width="100%">
                                <tr style="border:1px solid black;border-collapse: collapse;">
                                    <td style="text-align:left;">
                                        Consignee :
                                        <br/>
                                        Address :
                                        <br/>
                                        City :
                                        <br/>
                                        Mobile Number :
                                        <br/>
                                        ID No:
                                    </td>
                                    <td style="text-align:center;" colspan="2">
                                        <span t-if="o.x_studio_field_WJ3co.name"
                                              t-field="o.x_studio_field_WJ3co.name"/>
                                        <br/>
                                        <span t-if="o.x_studio_field_WJ3co.street"
                                              t-field="o.x_studio_field_WJ3co.street">,
                                        </span>
                                        <span t-if="o.x_studio_field_WJ3co.street2"
                                              t-field="o.x_studio_field_WJ3co.street2">,
                                        </span>
                                        <span t-if="o.x_studio_field_WJ3co.phone"
                                              t-field="o.x_studio_field_WJ3co.phone">,
                                        </span>
                                        <span t-if="o.x_studio_field_WJ3co.state_id.name"
                                              t-field="o.x_studio_field_WJ3co.state_id.name">,
                                        </span>
                                        <span t-if="o.x_studio_field_WJ3co.zip"
                                              t-field="o.x_studio_field_WJ3co.zip">,
                                        </span>
                                        <span t-if="o.x_studio_field_WJ3co.country_id.name"
                                              t-field="o.x_studio_field_WJ3co.country_id.name"/>
                                        <br/>
                                        <span t-if="o.x_studio_field_WJ3co.city"
                                              t-field="o.x_studio_field_WJ3co.city"/>
                                        <br/>
                                        <span t-if="o.x_studio_field_WJ3co.mobile"
                                              t-field="o.x_studio_field_WJ3co.mobile"/>
                                        <br/>
                                        <span t-if="o.x_studio_field_WJ3co.x_studio_id_no"
                                              t-field="o.x_studio_field_WJ3co.x_studio_id_no"/>
                                    </td>
                                    <td style="text-align:right;border-right:1px solid black;">
                                        :المستلم
                                        <br/>
                                        :العنوان
                                        <br/>
                                        :المدينة
                                        <br/>
                                        :رقم الجوال
                                        <br/>
                                        :رقم الهوية
                                    </td>

                                    <td style="text-align:left;">
                                        Sender:
                                        <br/>
                                        Address:
                                        <br/>
                                        City:
                                        <br/>
                                        Mobile Number:
                                        <br/>
                                        ID Number :
                                    </td>
                                    <td style="text-align:center;">
                                        <span t-if="o.partner_id.name"
                                              t-field="o.partner_id.name"/>
                                        <br/>
                                        <span t-if="o.partner_id.street"
                                              t-field="o.partner_id.street">,
                                        </span>
                                        <span t-if="o.partner_id.street2"
                                              t-field="o.partner_id.street2">,
                                        </span>
                                        <span t-if="o.partner_id.phone"
                                              t-field="o.partner_id.phone">,
                                        </span>
                                        <span t-if="o.partner_id.state_id.name"
                                              t-field="o.partner_id.state_id.name">,
                                        </span>
                                        <span t-if="o.partner_id.zip"
                                              t-field="o.partner_id.zip">,
                                        </span>
                                        <span t-if="o.partner_id.country_id.name"
                                              t-field="o.partner_id.country_id.name"/>
                                        <br/>
                                        <span t-if="o.partner_id.city"
                                              t-field="o.partner_id.city"/>
                                        <br/>
                                        <span t-if="o.partner_id.mobile"
                                              t-field="o.partner_id.mobile"/>
                                        <br/>
                                        <span t-if="o.partner_id.x_studio_id_no"
                                              t-field="o.partner_id.x_studio_id_no"/>
                                    </td>
                                    <td style="text-align:right;">
                                        المرسل
                                        <br/>
                                        :العنوان
                                        <br/>
                                        :المدينة
                                        <br/>
                                        :رقم الجوال
                                        <br/>
                                        :رقم الهوية
                                    </td>
                                </tr>
                            </tr>
                            <tr>
                                <tr t-foreach="o.order_line" t-as="l">
                                    <td style="text-align:left;" colspan="2">
                                        Untaxed Amount
                                        <br/>
                                        Taxes
                                        <br/>
                                        Total
                                    </td>
                                    <td style="text-align:center;">
                                        <span t-if="o.amount_untaxed"
                                              t-field="o.amount_untaxed"/>
                                        <br/>
                                        <span t-if="o.amount_tax"
                                              t-field="o.amount_tax"/>
                                        <br/>
                                        <span t-if="o.amount_total"
                                              t-field="o.amount_total"/>
                                    </td>
                                    <td style="text-align:right;">
                                        المجموع قبل الضرائب
                                        <br/>
                                        الضرائب
                                        <br/>
                                        المجموع النهائي
                                    </td>
                                    <td style="text-align:left;">
                                        Item
                                        <br/>
                                        Description
                                        <br/>
                                        Quantity
                                    </td>
                                    <td style="text-align:center;">
                                        <span t-if="l.product_id.name"
                                              t-field="l.product_id.name"/>
                                        <br/>
                                        <span t-if="l.name"
                                              t-field="l.name"/>
                                        <br/>
                                        <span t-if="l.product_uom_qty"
                                              t-field="l.product_uom_qty"/>
                                    </td>
                                    <td style="text-align:right;">
                                        الصنف
                                        <br/>
                                        الوصف
                                        <br/>
                                        العدد
                                    </td>
                                </tr>
                            </tr>
                        </table>
                    </div>
                </div>
            </t>
        </t>
    </template>
</odoo>

Now , how the report is getting is like below image. enter image description here

Now these all are the informations I can provide.

Thanks in advance.

1
@EasyOdoo : Can you look into this ?Pablo Escobar
Maybe in 'o.order_line' not get any value. Due to that, it getting blank.Avani Somaiya
@Avani Somaiya : Nope there is a field called order_line in the sale order model.Pablo Escobar

1 Answers

3
votes

Don't stack <tr> nodes. Just put the foreach into the first <tr>

<tr t-foreach="o.order_line" t-as="l">
    <!-- tds -->
</tr>