In this code, the section is printed after the line items. As shown in the image I shared, it should appear the related line items. Please help me fix it
<tbody class="invoice_tbody" style="border-bottom:2px solid gainsboro;">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
<t t-foreach="o.invoice_line_ids" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_subtotal_TTC" t-value="current_subtotal_TTC + line.price_total"/>
<tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
<td name="account_invoice_line_name">
<span t-field="line.name"/>
</td>
<!-- <td class="d-none">-->
<!-- <span t-field="line.origin"/>-->
<!-- </td>-->
<td class="text-end">
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.price_unit"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td t-if="display_discount"
t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.discount"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"/>
</td>
<td style="border-top-style: hidden;" class="text-end o_price_total">
<span t-field="line.price_subtotal"/>
</td>
<td style="border-top-style: hidden;" class="text-end o_price_total">
<span t-field="line.price_total"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td t-att-colspan="colspan" style="font-weight:bold;">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'"
style="font-size:11.5px !important;font-weight:bold;">
<td t-att-colspan="colspan" style="font-weight:bold; white-space: pre-wrap;">
<span t-esc="line.name"/>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or o.invoice_line_ids[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td></td>
<td></td>
<td></td>
<td>
<strong class="mr16">Sous-total</strong>
</td>
<td>
<span
t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/>
</td>
<td>
<span
t-esc="current_subtotal_TTC"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/>
</td>
</tr>
</t>
</t>
</tbody>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Buchhaltung
- Lager
- PoS
- Project
- MRP
Diese Frage wurde gekennzeichnet
Hi,
You need to move the section and note line checks (line.display_type == 'line_section' and line.display_type == 'line_note') above the product line rendering block.
Please refer to the code below:
<tbody class="invoice_tbody" style="border-bottom:2px solid gainsboro;">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
<t t-foreach="o.invoice_line_ids" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_subtotal_TTC" t-value="current_subtotal_TTC + line.price_total"/>
<tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="line.display_type == 'line_section'">
<td t-att-colspan="colspan" style="font-weight:bold;">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'"
style="font-size:11.5px !important;font-weight:bold;">
<td t-att-colspan="colspan" style="font-weight:bold; white-space: pre-wrap;">
<span t-esc="line.name"/>
</td>
</t>
<t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
<td name="account_invoice_line_name">
<span t-field="line.name"/>
</td>
<!-- <td class="d-none">-->
<!-- <span t-field="line.origin"/>-->
<!-- </td>-->
<td class="text-end">
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.price_unit"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td t-if="display_discount"
t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.discount"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"/>
</td>
<td style="border-top-style: hidden;" class="text-end o_price_total">
<span t-field="line.price_subtotal"/>
</td>
<td style="border-top-style: hidden;" class="text-end o_price_total">
<span t-field="line.price_total"/>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or o.invoice_line_ids[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td></td>
<td></td>
<td></td>
<td>
<strong class="mr16">Sous-total</strong>
</td>
<td>
<span
t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/>
</td>
<td>
<span
t-esc="current_subtotal_TTC"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'
/>
</td>
</tr>
</t>
</t>
</tbody>
Hope it helps.
I have tried your code but still section is appeared at last, any ways thank you
Maybe try to move the line.display_type == 'line_section' logic before the main <tr> is rendered so that the section row prints before the associated product lines. Like this:
<tbody class="invoice_tbody" style="border-bottom:2px solid gainsboro;">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
<t t-foreach="o.invoice_line_ids" t-as="line" t-index="line_index">
<!-- SECTION HEADER FIRST -->
<t t-if="line.display_type == 'line_section'">
<tr class="bg-200 font-weight-bold o_line_section">
<td t-att-colspan="colspan" style="font-weight:bold;">
<span t-field="line.name"/>
</td>
</tr>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_subtotal_TTC" t-value="0"/>
</t>
<!-- NOTE LINE -->
<t t-if="line.display_type == 'line_note'">
<tr class="font-italic o_line_note">
<td t-att-colspan="colspan" style="font-weight:bold; white-space: pre-wrap;">
<span t-esc="line.name"/>
</td>
</tr>
</t>
<!-- PRODUCT LINE -->
<t t-if="line.display_type == 'product'" name="account_invoice_line_accountable">
<tr>
<td name="account_invoice_line_name">
<span t-field="line.name"/>
</td>
<td class="text-end">
<span t-field="line.quantity"/>
<span t-field="line.product_uom_id" groups="uom.group_uom"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.price_unit" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td t-if="display_discount"
t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.discount"/>
</td>
<td t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_ids))"/>
</td>
<td class="text-end o_price_total" style="border-top-style: hidden;">
<span t-field="line.price_subtotal"/>
</td>
<td class="text-end o_price_total" style="border-top-style: hidden;">
<span t-field="line.price_total"/>
</td>
</tr>
<!-- Update subtotals -->
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_subtotal_TTC" t-value="current_subtotal_TTC + line.price_total"/>
</t>
<!-- SUBTOTAL AFTER LAST LINE IN SECTION -->
<t t-if="current_section and (line_index + 1 == len(o.invoice_line_ids) or o.invoice_line_ids[line_index + 1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td></td><td></td><td></td>
<td><strong class="mr16">Sous-total</strong></td>
<td>
<span t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
<td>
<span t-esc="current_subtotal_TTC"
t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
</t>
</tbody>
Diskutieren Sie gerne? Treten Sie bei, statt nur zu lesen!
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
RegistrierenVerknüpfte Beiträge | Antworten | Ansichten | Aktivität | |
---|---|---|---|---|
|
0
Juli 25
|
3 | ||
|
0
Aug. 25
|
50 | ||
|
0
Aug. 25
|
3 | ||
|
1
Aug. 25
|
243 | ||
|
0
Aug. 25
|
404 |