Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
473 Widoki

Hello, i am trying to create a custom customer statement template in odoo17 but i keep getting this error in the terminal that doesn't quite make sense, i have reviewed my code, given it to AI and still nothing but the same error:



odoo.tools.convert.ParseError: while parsing None:4

Error while parsing or validating view:


Element '<t t-name="zra_smart_invoice.report_customer_statement_aged">' cannot be located in parent view


View error context:

{'file': 'c:\\program '

'files\\odoo17\\odoo17-dev\\custom\\zra_smart_invoice\\report\\report_customer_statement_aged.xml',

'line': 2,

'name': 'report_customer_statement_aged',

'view': ir.ui.view(2191,),

'view.model': False,

'view.parent': ir.ui.view(2089,),

'xmlid': 'report_customer_statement_aged'}


I don't know if this forum deals with coding in odoo but i really just need help


here is the custom XML code


        <!-- Customer Statement Report -->
   <record id="action_print_customer_statement_aged" model="ir.actions.report">
    <field name="name">Print Aged Statement</field>
    <field name="model">res.partner</field>
    <field name="report_type">qweb-pdf</field>
    <field name="report_name">zra_smart_invoice.report_customer_statement_aged</field>
    <field name="report_file">zra_smart_invoice.report_customer_statement_aged</field>
    <field name="print_report_name">'Statement - %s' % (object.name)</field>
    <field name="binding_model_id" ref="model_res_partner"/>
    <field name="binding_type">report</field>
</record>


<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!-- Main report template (MUST be this exact structure) -->
    <template id="report_customer_statement_aged">
    <t t-name="zra_smart_invoice.report_customer_statement_aged">
        <t t-call="zra_smart_invoice.external_layout">
            <t t-foreach="docs" t-as="doc">
             
                    <div class="page">
                        <!-- Header Section -->
                        <div class="header" style="margin-bottom: 20px;">
                            <h1 style="text-align: center;">CUSTOMER STATEMENT</h1>
                            <div style="text-align: center;">
                                <span t-out="context.get('date_from')"/> to <span t-out="context.get('date_to')"/>
                            </div>
                        </div>

                        <!-- Customer Info -->
                        <div style="margin-bottom: 30px;">
                            <address t-field="doc" t-options="{'widget': 'contact', 'fields': ['address', 'name', 'vat'], 'no_marker': True}"/>
                        </div>

                        <!-- Transactions Table -->
                        <t t-set="statement_lines" t-value="doc._get_statement_lines()"/>
                        <table class="table table-bordered" style="width: 100%;">
                            <thead>
                                <tr>
                                    <th>Date</th>
                                    <th>Description</th>
                                    <th>Due Date</th>
                                    <th class="text-end">Amount</th>
                                    <th class="text-end">Balance</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr t-foreach="statement_lines" t-as="line">
                                    <td><span t-out="line.get('date')"/></td>
                                    <td><span t-out="line.get('activity')"/></td>
                                    <td><span t-out="line.get('due_date')"/></td>
                                    <td class="text-end">
                                        <span t-out="line.get('amount')" t-options="{'widget': 'monetary', 'display_currency': doc.company_id.currency_id}"/>
                                    </td>
                                    <td class="text-end">
                                        <span t-out="line.get('balance')" t-options="{'widget': 'monetary', 'display_currency': doc.company_id.currency_id}"/>
                                    </td>
                                </tr>
                            </tbody>
                        </table>

                        <!-- Aging Analysis -->
                        <div style="margin-top: 40px;">
                            <h3 style="border-bottom: 1px solid #000;">AGING ANALYSIS</h3>
                            <t t-set="aging_data" t-value="doc._get_aging_data()"/>
                            <table class="table" style="width: 100%;">
                                <tr>
                                    <td class="text-center"><strong>Current</strong></td>
                                    <td class="text-center"><strong>1-30 Days</strong></td>
                                    <td class="text-center"><strong>31-60 Days</strong></td>
                                    <td class="text-center"><strong>61-90 Days</strong></td>
                                    <td class="text-center"><strong>Over 90 Days</strong></td>
                                </tr>
                                <tr>
                                    <td class="text-center" t-out="aging_data.get('current', 0.0)" t-options="{'widget': 'monetary'}"/>
                                    <td class="text-center" t-out="aging_data.get('1-30', 0.0)" t-options="{'widget': 'monetary'}"/>
                                    <td class="text-center" t-out="aging_data.get('31-60', 0.0)" t-options="{'widget': 'monetary'}"/>
                                    <td class="text-center" t-out="aging_data.get('61-90', 0.0)" t-options="{'widget': 'monetary'}"/>
                                    <td class="text-center" t-out="aging_data.get('over_90', 0.0)" t-options="{'widget': 'monetary'}"/>
                                </tr>
                            </table>
                        </div>
                    </div>
                </t>
            </t>
        </t>
    </template>
</odoo>

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,


You are not inheriting a view, but you're defining a standalone QWeb report template, which means your outer <template> should not have a parent reference, and your XML needs proper registration.


Try the following.


Change the template as,


<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDF Template for Customer Statement -->
<template id="report_customer_statement_aged">
<t t-name="zra_smart_invoice.report_customer_statement_aged">
<t t-call="web.external_layout">
<t t-foreach="docs" t-as="doc">
<div class="page">
<!-- Your layout here -->
</div>
</t>
</t>
</t>
</template>
</odoo>


Ensure you are using t-name, not nesting inside another <template> tag unless you are explicitly inheriting. Also, use web.external_layout or your custom layout like zra_smart_invoice.external_layout only if it exists.


Hope it helps

Awatar
Odrzuć
Najlepsza odpowiedź

The three most likely reasons for Element 'x' cannot be located in parent view are:

  • it really just doesn't exist
  • typos
  • the sequence of loading data and view files or the records inside

While you will have to check for typos on your own, the second reason, sequence of loading, means that 'zra_smart_invoice.report_customer_statement_aged' must be defined prior to it being used (i.e. in the data key in your manifest make sure the file holding the definition is loaded before anything that needs it; and, inside one xml file, make sure it is likewise defined prior to being used).

Here however, I have no idea what <t t-name="zra_smart_invoice.report_customer_statement_aged"> is supposed to be as it seems to be the same as the template it is actually using.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
sty 18
3182
2
cze 25
2287
1
sie 24
1316
0
sie 24
1558
1
cze 24
1546