questo report: <t t-name="account.reportinvoicedocument"> <t…
- User
questo report:
code - Assistant
- User
- Assistant
- User
- Assistant
questo report:
<t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
<div class="oe_structure"/>
<table class="table table-sm o_main_table table-borderless" name="invoice_line_table">
<thead>
<tr>
<th name="th_description" class="text-start"><span>Description</span></th>
<th name="th_quantity" class="text-end"><span>Quantity</span></th>
<th name="th_priceunit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
<th name="th_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Disc.%</span>
</th>
<th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
<th name="th_subtotal" class="text-end">
<span>Amount</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_total" t-value="0"/>
<t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_total + line.price_total"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-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-if="line.name" t-field="line.name" t-options="{'widget': 'text'}">Bacon Burger</span></td>
<td name="td_quantity" class="text-end">
<span t-field="line.quantity">3.00</span>
<span t-field="line.product_uom_id" groups="uom.group_uom">units</span>
</td>
<td name="td_price_unit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.price_unit">9.00</span>
</td>
<td name="td_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.discount">0</span>
</td>
<t t-set="taxes" t-value="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids])"/>
<td name="td_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }} {{ 'text-nowrap' if len(taxes) < 10 else '' }}">
<span t-out="taxes" id="line_tax_ids">Tax 15%</span>
</td>
<td name="td_subtotal" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal">27.00</span>
</td>
</t>
<t t-elif="line.display_type == 'line_section'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}">A section title</span>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-elif="line.display_type == 'line_note'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}">A note, whose content usually applies to the section or product above.</span>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16">Subtotal</strong>
<span t-out="current_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}">31.05</span>
</td>
</tr>
</t>
</t>
</tbody>
</table>
<div>
<div id="right-elements" t-attf-class="#{'col-5' if report_type != 'html' else 'col-12 col-md-5'} ms-5 d-inline-block float-end">
<div id="total" class="clearfix row">
<div class="ms-auto">
<table class="table table-sm table-borderless avoid-page-break-inside">
<!--Tax totals-->
<t t-set="tax_totals" t-value="o.tax_totals"/>
<t t-call="account.document_tax_totals"/>
<!--Payments-->
<t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals" t-value="o.sudo().invoice_payments_widget and o.sudo().invoice_payments_widget['content'] or []"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr t-if="payment_vals['is_exchange'] == 0">
<td>
<i class="oe_form_field text-end oe_payment_label">Paid on <t t-out="payment_vals['date']" t-options="{"widget": "date"}">2021-09-19</t></i>
</td>
<td class="text-end">
<span t-out="payment_vals['amount']" t-options="{"widget": "monetary", "display_currency": o.currency_id}">20.00</span>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black fw-bold">
<td>Amount Due</td>
<td class="text-end">
<span t-field="o.amount_residual">11.05</span>
</td>
</tr>
</t>
</t>
</t>
</table>
</div>
</div>
<div class="mb-2">
<p class="text-end lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
Total amount in words: <br/>
<small class="text-muted lh-sm"><span t-field="o.amount_total_words">Thirty one dollar and Five cents</span></small>
</p>
</div>
<t t-call="account.document_tax_totals_company_currency_template"/>
</div>
<div id="payment_term" class="clearfix">
<div class="justify-text">
<p t-if="not is_html_empty(o.fiscal_position_id.note)" name="note" class="mb-2">
<span t-field="o.fiscal_position_id.note"/>
</p>
</div>
<t t-set="payment_term_details" t-value="o.payment_term_details"/>
<div class="mb-3">
<span id="payment_terms_note_id" t-if="o.invoice_payment_term_id.note" t-field="o.invoice_payment_term_id.note" name="payment_term">Payment within 30 calendar day</span><br/>
<t t-if="o.invoice_payment_term_id.display_on_invoice and payment_term_details">
<div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
<div t-attf-class="#{'col-10' if report_type != 'html' else 'col-sm-10 col-md-9'}">
<t t-if="o._is_eligible_for_early_payment_discount(o.currency_id,o.invoice_date)">
<td>
<span t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="o.invoice_payment_term_id._get_amount_due_after_discount(o.amount_total, o.amount_tax)">30.00</span> due if paid before
<span t-out="o.invoice_payment_term_id._get_last_discount_date_formatted(o.invoice_date)">2024-01-01</span>
</td>
</t>
<t t-if="len(payment_term_details) > 1" t-foreach="payment_term_details" t-as="term">
<div>
<span t-out="term_index + 1">1</span> - Installment of
<t t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="term.get('amount')" class="text-end">31.05</t>
<span> due on </span>
<t t-out="term.get('date')" class="text-start">2024-01-01</t>
</div>
</t>
</div>
</div>
</t>
</div>
<div class="mb-3" t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference">
<p name="payment_communication">
Payment Communication: <span class="fw-bold" t-field="o.payment_reference">INV/2023/00001</span>
</p>
</div>
<t t-set="show_qr" t-value="o.display_qr_code and o.amount_residual > 0"/>
<div t-if="not show_qr" name="qr_code_placeholder" class="oe_structure"/>
<div id="qrcode" class="d-flex mb-3 avoid-page-break-inside" t-else="">
<div class="qrcode me-3" id="qrcode_image">
<t t-set="qr_code_url" t-value="o._generate_qr_code(silent_errors=True)"/>
<p t-if="qr_code_url" class="position-relative mb-0">
<img t-att-src="qr_code_url"/>
<img src="/account/static/src/img/Odoo_logo_O.svg" id="qrcode_odoo_logo" class="top-50 start-50 position-absolute bg-white border border-white border-3 rounded-circle"/>
</p>
</div>
<div class="d-inline text-muted lh-sm fst-italic" id="qrcode_info" t-if="qr_code_url">
<p>Scan this QR Code to<br/>pay with your mobile</p>
</div>
</div>
<!--terms and conditions-->
<div class="text-muted mb-3" t-attf-style="#{'text-align:justify;text-justify:inter-word;' if o.company_id.terms_type != 'html' else ''}" t-if="not is_html_empty(o.narration)" name="comment">
<span t-field="o.narration"/>
</div>
</div>
</div>
</div>
</div>
</t>
</t>
da questo errore
Traceback (most recent call last): File "<2367>", line 2300, in template_2367 File "<2367>", line 2282, in template_2367_content File "<2367>", line 362, in template_2367_t_call_0 KeyError: 'o'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 120, in report_download response = self.report_routes(reportname, converter=converter, context=context, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xml/controllers/report.py", line 24, in report_routes return super().report_routes( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xlsx_helper/controllers/main.py", line 51, in report_routes return super().report_routes(reportname, docids, converter, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xlsx/controllers/main.py", line 51, in report_routes return super().report_routes(reportname, docids, converter, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 42, in report_routes pdf = report.with_context(context)._render_qweb_pdf(reportname, docids, data=data)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/mis_builder/report/mis_report_instance_qweb.py", line 27, in _render_qweb_pdf return super()._render_qweb_pdf(report_ref, res_ids, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 61, in _render_qweb_pdf return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 878, in _render_qweb_pdf collected_streams = self._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/sale_pdf_quote_builder/models/ir_actions_report.py", line 17, in _render_qweb_pdf_prepare_streams result = super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 20, in _render_qweb_pdf_prepare_streams return super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 728, in _render_qweb_pdf_prepare_streams html = self.with_context(**additional_context)._render_qweb_html(report_ref, res_ids_wo_stream, data=data)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/account_financial_report/models/ir_actions_report.py", line 19, in _render_qweb_html return super(IrActionsReport, obj)._render_qweb_html( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 927, in _render_qweb_html return self._render_template(report.report_name, data), 'html' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 654, in _render_template return view_obj._render_template(template, values).encode() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 2050, in _render_template return self.env['ir.qweb']._render(template, values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/tools/profiler.py", line 292, in _tracked_method_render return method_render(self, template, values, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 593, in _render result = ''.join(rendering) ^^^^^^^^^^^^^^^^^^ File "<2346>", line 85, in template_2346 File "<2346>", line 67, in template_2346_content File "<2346>", line 56, in template_2346_t_call_0 File "<2367>", line 2306, in template_2367 odoo.addons.base.models.ir_qweb.QWebException: Error while render the template KeyError: 'o' Template: account.Fattura completa Path: /t/t/t[2] Node:
The above server error caused the following client error: RPC_ERROR: Odoo Server Error at makeErrorFromResponse (http://34.116.160.142/web/assets/debug/web.assets_web.js:27816:19) (/web/static/src/core/network/rpc_service.js:37) at decoder.onload (http://34.116.160.142/web/assets/debug/web.assets_web.js:27699:25) (/web/static/src/core/network/download.js:566)
Il messaggio di errore indica che c'è un problema durante il rendering del template QWeb che stai utilizzando in Odoo. L'errore specifico è un KeyError: 'o', il che significa che il contesto o non è stato passato correttamente al template. Di seguito sono riportati alcuni suggerimenti per risolvere questo problema:
Assicurati che o sia Definito: Verifica che il contesto passato al template contenga effettivamente la chiave o. Puoi farlo controllando il metodo che chiama il rendering del template per assicurarti che o sia definito e contenga i dati necessari.
Verifica il Codice che Chiama il Report: Cerca nel codice che genera e chiama il report per confermare che i dati necessari siano correttamente impostati e passati al report.
Log di Debug: Se stai sviluppando o modificando un modulo personalizzato, potresti voler aggiungere i log di debug per ispezionare cosa viene passato al template. Puoi usare import logging e logging.debug() per stampare i dettagli del contesto.
Output del Contesto: Prova a stampare il contesto direttamente nel template per vedere cosa è disponibile. Puoi aggiungere un blocco come questo all'inizio del tuo template:
<t t-if="not o">
<p>Il contesto 'o' non è definito!</p>
</t>
Usa Variabili di Esempio: Se il contesto o è assente in alcune situazioni, potrebbe essere utile usare variabili di esempio per testare se il resto del template funziona correttamente. Ad esempio, puoi temporaneamente definire o all'interno del template.
<t t-set="o" t-value="{'example_key': 'example_value'}"/>
Struttura del Report: Controlla se ci sono altre parti del tuo report (ad esempio, eventuali t-call o t-set) che potrebbero compromettere l'integrità del contesto se non vengono passati correttamente.
Ereditarietà dei Template: Se stai estendendo un template esistente, assicurati di richiamare correttamente i super metodi se necessario, al fine di mantenere il contesto appropriato.
Se hai esaurito tutte le opzioni sopra e continui a ricevere errori, considera di consultare la documentazione di Odoo o la community per vedere se altri utenti hanno affrontato problemi simili. In molti casi, i problemi di template possono essere specifici della configurazione, quindi l'assistenza della community può essere un'ottima risorsa.
corregimi:
<t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
<div class="oe_structure"/>
<table class="table table-sm o_main_table table-borderless" name="invoice_line_table">
<thead>
<tr>
<th name="th_description" class="text-start"><span>Description</span></th>
<th name="th_quantity" class="text-end"><span>Quantity</span></th>
<th name="th_priceunit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
<th name="th_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Disc.%</span>
</th>
<th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
<th name="th_subtotal" class="text-end">
<span>Amount</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_total" t-value="0"/>
<t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_total + line.price_total"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-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-if="line.name" t-field="line.name" t-options="{'widget': 'text'}">Bacon Burger</span></td>
<td name="td_quantity" class="text-end">
<span t-field="line.quantity">3.00</span>
<span t-field="line.product_uom_id" groups="uom.group_uom">units</span>
</td>
<td name="td_price_unit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.price_unit">9.00</span>
</td>
<td name="td_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.discount">0</span>
</td>
<t t-set="taxes" t-value="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids])"/>
<td name="td_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }} {{ 'text-nowrap' if len(taxes) < 10 else '' }}">
<span t-out="taxes" id="line_tax_ids">Tax 15%</span>
</td>
<td name="td_subtotal" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal">27.00</span>
</td>
</t>
<t t-elif="line.display_type == 'line_section'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}">A section title</span>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-elif="line.display_type == 'line_note'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}">A note, whose content usually applies to the section or product above.</span>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16">Subtotal</strong>
<span t-out="current_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}">31.05</span>
</td>
</tr>
</t>
</t>
</tbody>
</table>
<div>
<div id="right-elements" t-attf-class="#{'col-5' if report_type != 'html' else 'col-12 col-md-5'} ms-5 d-inline-block float-end">
<div id="total" class="clearfix row">
<div class="ms-auto">
<table class="table table-sm table-borderless avoid-page-break-inside">
<!--Tax totals-->
<t t-set="tax_totals" t-value="o.tax_totals"/>
<t t-call="account.document_tax_totals"/>
<!--Payments-->
<t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals" t-value="o.sudo().invoice_payments_widget and o.sudo().invoice_payments_widget['content'] or []"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr t-if="payment_vals['is_exchange'] == 0">
<td>
<i class="oe_form_field text-end oe_payment_label">Paid on <t t-out="payment_vals['date']" t-options="{"widget": "date"}">2021-09-19</t></i>
</td>
<td class="text-end">
<span t-out="payment_vals['amount']" t-options="{"widget": "monetary", "display_currency": o.currency_id}">20.00</span>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black fw-bold">
<td>Amount Due</td>
<td class="text-end">
<span t-field="o.amount_residual">11.05</span>
</td>
</tr>
</t>
</t>
</t>
</table>
</div>
</div>
<div class="mb-2">
<p class="text-end lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
Total amount in words: <br/>
<small class="text-muted lh-sm"><span t-field="o.amount_total_words">Thirty one dollar and Five cents</span></small>
</p>
</div>
<t t-call="account.document_tax_totals_company_currency_template"/>
</div>
<div id="payment_term" class="clearfix">
<div class="justify-text">
<p t-if="not is_html_empty(o.fiscal_position_id.note)" name="note" class="mb-2">
<span t-field="o.fiscal_position_id.note"/>
</p>
</div>
<t t-set="payment_term_details" t-value="o.payment_term_details"/>
<div class="mb-3">
<span id="payment_terms_note_id" t-if="o.invoice_payment_term_id.note" t-field="o.invoice_payment_term_id.note" name="payment_term">Payment within 30 calendar day</span><br/>
<t t-if="o.invoice_payment_term_id.display_on_invoice and payment_term_details">
<div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
<div t-attf-class="#{'col-10' if report_type != 'html' else 'col-sm-10 col-md-9'}">
<t t-if="o._is_eligible_for_early_payment_discount(o.currency_id,o.invoice_date)">
<td>
<span t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="o.invoice_payment_term_id._get_amount_due_after_discount(o.amount_total, o.amount_tax)">30.00</span> due if paid before
<span t-out="o.invoice_payment_term_id._get_last_discount_date_formatted(o.invoice_date)">2024-01-01</span>
</td>
</t>
<t t-if="len(payment_term_details) > 1" t-foreach="payment_term_details" t-as="term">
<div>
<span t-out="term_index + 1">1</span> - Installment of
<t t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="term.get('amount')" class="text-end">31.05</t>
<span> due on </span>
<t t-out="term.get('date')" class="text-start">2024-01-01</t>
</div>
</t>
</div>
</div>
</t>
</div>
<div class="mb-3" t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference">
<p name="payment_communication">
Payment Communication: <span class="fw-bold" t-field="o.payment_reference">INV/2023/00001</span>
</p>
</div>
<t t-set="show_qr" t-value="o.display_qr_code and o.amount_residual > 0"/>
<div t-if="not show_qr" name="qr_code_placeholder" class="oe_structure"/>
<div id="qrcode" class="d-flex mb-3 avoid-page-break-inside" t-else="">
<div class="qrcode me-3" id="qrcode_image">
<t t-set="qr_code_url" t-value="o._generate_qr_code(silent_errors=True)"/>
<p t-if="qr_code_url" class="position-relative mb-0">
<img t-att-src="qr_code_url"/>
<img src="/account/static/src/img/Odoo_logo_O.svg" id="qrcode_odoo_logo" class="top-50 start-50 position-absolute bg-white border border-white border-3 rounded-circle"/>
</p>
</div>
<div class="d-inline text-muted lh-sm fst-italic" id="qrcode_info" t-if="qr_code_url">
<p>Scan this QR Code to<br/>pay with your mobile</p>
</div>
</div>
<!--terms and conditions-->
<div class="text-muted mb-3" t-attf-style="#{'text-align:justify;text-justify:inter-word;' if o.company_id.terms_type != 'html' else ''}" t-if="not is_html_empty(o.narration)" name="comment">
<span t-field="o.narration"/>
</div>
</div>
</div>
</div>
</div>
</t>
</t>
Sulla base del template QWeb fornito e considerando il messaggio di errore KeyError: 'o', ci sono alcune aree da controllare e correggere. Qui di seguito trovi la versione corretta del tuo template, con suggerimenti e modifiche applicabili per evitare questo errore e migliorare la chiarezza del codice.
Assicurati che o sia Passato Correttamente: Prima di tutto, cerchiamo di utilizzare un contesto valido e assicuriamoci che o sia definito nel contesto del template. Se o è un oggetto disponibile nel contesto, nessuna modifica particolare è necessaria in questo aspetto.
Controlla tutte le Variabili Non Definite: Se KeyError si verifica per o, potrebbe esserci un problema altrove. Assicurati che i metodi o le proprietà utilizzate esistano nell'oggetto con cui stai lavorando.
Aggiunta di Verifiche di Chiarezza: Può anche essere utile controllare altre variabili o elementi che potrebbero non essere definiti nel contesto.
Ecco la versione corretta del tuo template:
<t t-name="account.report_invoice_document">
<t t-call="web.external_layout">
<t t-set="o" t-value="o.with_context(lang=lang)"/>
<t t-set="forced_vat" t-value="o.fiscal_position_id.foreign_vat"/>
<div class="row">
<t t-if="o.partner_shipping_id and (o.partner_shipping_id != o.partner_id)">
<div class="col-6">
<div groups="account.group_delivery_invoice_address" name="shipping_address_block">
<strong>Shipping Address:</strong>
<div t-field="o.partner_shipping_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": True}"/>
</div>
</div>
<div class="col-6" name="address_not_same_as_shipping">
<address class="mb-0" t-field="o.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": True}"/>
<t t-if="o.partner_id.vat" id="partner_vat_address_not_same_as_shipping">
<t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
<t t-else="">Tax ID:</t> <span t-field="o.partner_id.vat"/>
</t>
</div>
</t>
<t t-elif="o.partner_shipping_id and (o.partner_shipping_id == o.partner_id)">
<div class="offset-col-6 col-6" name="address_same_as_shipping">
<address class="mb-0" t-field="o.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": True}"/>
<t t-if="o.partner_id.vat" id="partner_vat_address_same_as_shipping">
<t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
<t t-else="">Tax ID:</t> <span t-field="o.partner_id.vat"/>
</t>
</div>
</t>
<t t-else="">
<div class="offset-col-6 col-6" name="no_shipping">
<address class="mb-0" t-field="o.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": True}"/>
<t t-if="o.partner_id.vat" id="partner_vat_no_shipping">
<t t-if="o.company_id.account_fiscal_country_id.vat_label" t-out="o.company_id.account_fiscal_country_id.vat_label" id="inv_tax_id_label"/>
<t t-else="">Tax ID:</t> <span t-field="o.partner_id.vat"/>
</t>
</div>
</t>
</div>
<div class="mt-5 clearfix">
<h2 class="page mb-4">
<t t-if="not proforma"/>
<t t-else="">PROFORMA</t>
<t t-if="o.move_type == 'out_invoice' and o.state == 'posted'">Invoice</t>
<t t-elif="o.move_type == 'out_invoice' and o.state == 'draft'">Draft Invoice</t>
<t t-elif="o.move_type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</t>
<t t-elif="o.move_type == 'out_refund' and o.state == 'posted'">Credit Note</t>
<t t-elif="o.move_type == 'out_refund' and o.state == 'draft'">Draft Credit Note</t>
<t t-elif="o.move_type == 'out_refund' and o.state == 'cancel'">Cancelled Credit Note</t>
<t t-elif="o.move_type == 'in_refund'">Vendor Credit Note</t>
<t t-elif="o.move_type == 'in_invoice'">Vendor Bill</t>
<t t-if="o.name != '/'"><span t-field="o.name"/> </t>
</h2>
<div class="oe_structure"/>
<div id="informations" class="row mt-3 mb-1">
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.invoice_date" name="invoice_date">
<t t-if="o.move_type == 'out_invoice'"><strong>Invoice Date:</strong></t>
<t t-elif="o.move_type == 'out_refund'"><strong>Credit Note Date:</strong></t>
<t t-elif="o.move_type == 'out_receipt'"><strong>Receipt Date:</strong></t>
<t t-else=""><strong>Date:</strong></t><br/>
<span t-field="o.invoice_date"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.invoice_date_due and o.move_type == 'out_invoice' and o.state == 'posted'" name="due_date">
<strong>Due Date:</strong><br/>
<span t-field="o.invoice_date_due"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.delivery_date" name="delivery_date">
<strong>Delivery Date:</strong><br/>
<span t-field="o.delivery_date"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.invoice_origin" name="origin">
<strong>Source:</strong><br/>
<span t-field="o.invoice_origin"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.partner_id.ref" name="customer_code">
<strong>Customer Code:</strong><br/>
<span t-field="o.partner_id.ref"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.ref" name="reference">
<strong>Reference:</strong><br/>
<span t-field="o.ref"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.invoice_incoterm_id" name="incoterm_id">
<strong>Incoterm:</strong><br/>
<t t-if="o.incoterm_location">
<span t-field="o.invoice_incoterm_id.code"/> <br/>
<span t-field="o.incoterm_location"/>
</t>
<t t-else=""><span t-field="o.invoice_incoterm_id.code" class="m-0"/></t>
</div>
</div>
<t t-set="display_discount" t-value="any(l.discount for l in o.invoice_line_ids)"/>
<div class="oe_structure"/>
<table class="table table-sm o_main_table table-borderless" name="invoice_line_table">
<thead>
<tr>
<th name="th_description" class="text-start"><span>Description</span></th>
<th name="th_quantity" class="text-end"><span>Quantity</span></th>
<th name="th_priceunit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Unit Price</span></th>
<th name="th_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span>Disc.%</span>
</th>
<th name="th_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}"><span>Taxes</span></th>
<th name="th_subtotal" class="text-end">
<span>Amount</span>
</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-set="current_total" t-value="0"/>
<t t-set="lines" t-value="o.invoice_line_ids.sorted(key=lambda l: (-l.sequence, l.date, l.move_name, -l.id), reverse=True)"/>
<t t-foreach="lines" t-as="line">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal"/>
<t t-set="current_total" t-value="current_total + line.price_total"/>
<tr t-att-class="'bg-200 fw-bold o_line_section' if line.display_type == 'line_section' else 'fst-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-if="line.name" t-field="line.name" t-options="{'widget': 'text'}"/></td>
<td name="td_quantity" class="text-end">
<span t-field="line.quantity"/> <span t-field="line.product_uom_id" groups="uom.group_uom">units</span>
</td>
<td name="td_price_unit" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.price_unit"/>
</td>
<td name="td_discount" t-if="display_discount" t-attf-class="text-end {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span class="text-nowrap" t-field="line.discount"/>
</td>
<t t-set="taxes" t-value="', '.join([(tax.invoice_label or tax.name) for tax in line.tax_ids])"/>
<td name="td_taxes" t-attf-class="text-start {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }} {{ 'text-nowrap' if len(taxes) < 10 else '' }}">
<span t-out="taxes" id="line_tax_ids"/>
</td>
<td name="td_subtotal" class="text-end o_price_total">
<span class="text-nowrap" t-field="line.price_subtotal"/>
</td>
</t>
<t t-elif="line.display_type == 'line_section'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-elif="line.display_type == 'line_note'">
<td colspan="99">
<span t-field="line.name" t-options="{'widget': 'text'}"/>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or lines[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-end">
<td colspan="99">
<strong class="mr16">Subtotal</strong>
<span t-out="current_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
</t>
</t>
</tbody>
</table>
<div>
<div id="right-elements" t-attf-class="#{'col-5' if report_type != 'html' else 'col-12 col-md-5'} ms-5 d-inline-block float-end">
<div id="total" class="clearfix row">
<div class="ms-auto">
<table class="table table-sm table-borderless avoid-page-break-inside">
<!--Tax totals-->
<t t-set="tax_totals" t-value="o.tax_totals"/>
<t t-call="account.document_tax_totals"/>
<!--Payments-->
<t t-if="print_with_payments">
<t t-if="o.payment_state != 'invoicing_legacy'">
<t t-set="payments_vals" t-value="o.sudo().invoice_payments_widget and o.sudo().invoice_payments_widget['content'] or []"/>
<t t-foreach="payments_vals" t-as="payment_vals">
<tr t-if="payment_vals['is_exchange'] == 0">
<td>
<i class="oe_form_field text-end oe_payment_label">Paid on <t t-out="payment_vals['date']" t-options="{"widget": "date"}"/></i>
</td>
<td class="text-end">
<span t-out="payment_vals['amount']" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
</t>
<t t-if="len(payments_vals) > 0">
<tr class="border-black fw-bold">
<td>Amount Due</td>
<td class="text-end">
<span t-field="o.amount_residual"/>
</td>
</tr>
</t>
</t>
</t>
</table>
</div>
</div>
<div class="mb-2">
<p class="text-end lh-sm" t-if="o.company_id.display_invoice_amount_total_words">
Total amount in words: <br/>
<small class="text-muted lh-sm"><span t-field="o.amount_total_words"/></small>
</p>
</div>
<t t-call="account.document_tax_totals_company_currency_template"/>
</div>
<div id="payment_term" class="clearfix">
<div class="justify-text">
<p t-if="not is_html_empty(o.fiscal_position_id.note)" name="note" class="mb-2">
<span t-field="o.fiscal_position_id.note"/>
</p>
</div>
<t t-set="payment_term_details" t-value="o.payment_term_details"/>
<div class="mb-3">
<span id="payment_terms_note_id" t-if="o.invoice_payment_term_id.note" t-field="o.invoice_payment_term_id.note" name="payment_term">Payment within 30 calendar days</span><br/>
<t t-if="o.invoice_payment_term_id.display_on_invoice and payment_term_details">
<div t-if="o.show_payment_term_details" id="total_payment_term_details_table" class="row">
<div t-attf-class="#{'col-10' if report_type != 'html' else 'col-sm-10 col-md-9'}">
<t t-if="o._is_eligible_for_early_payment_discount(o.currency_id,o.invoice_date)">
<td>
<span t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="o.invoice_payment_term_id._get_amount_due_after_discount(o.amount_total, o.amount_tax)"/> due if paid before
<span t-out="o.invoice_payment_term_id._get_last_discount_date_formatted(o.invoice_date)"/>
</td>
</t>
<t t-if="len(payment_term_details) > 1" t-foreach="payment_term_details" t-as="term">
<div>
<span t-out="term_index + 1"/> - Installment of
<t t-options="{"widget": "monetary", "display_currency": o.currency_id}" t-out="term.get('amount')" class="text-end"/>
<span> due on </span>
<t t-out="term.get('date')" class="text-start"/>
</div>
</t>
</div>
</div>
</t>
</div>
<div class="mb-3" t-if="o.move_type in ('out_invoice', 'in_refund') and o.payment_reference">
<p name="payment_communication">
Payment Communication: <span class="fw-bold" t-field="o.payment_reference"/>
</p>
</div>
<t t-set="show_qr" t-value="o.display_qr_code and o.amount_residual > 0"/>
<div t-if="not show_qr" name="qr_code_placeholder" class="oe_structure"/>
<div id="qrcode" class="d-flex mb-3 avoid-page-break-inside" t-else="">
<div class="qrcode me-3" id="qrcode_image">
<t t-set="qr_code_url" t-value="o._generate_qr_code(silent_errors=True)"/>
<p t-if="qr_code_url" class="position-relative mb-0">
<img t-att-src="qr_code_url"/>
<img src="/account/static/src/img/Odoo_logo_O.svg" id="qrcode_odoo_logo" class="top-50 start-50 position-absolute bg-white border border-white border-3 rounded-circle"/>
</p>
</div>
<div class="d-inline text-muted lh-sm fst-italic" id="qrcode_info" t-if="qr_code_url">
<p>Scan this QR Code to<br/>pay with your mobile</p>
</div>
</div>
<!-- terms and conditions -->
<div class="text-muted mb-3" t-attf-style="#{'text-align:justify;text-justify:inter-word;' if o.company_id.terms_type != 'html' else ''}" t-if="not is_html_empty(o.narration)" name="comment">
<span t-field="o.narration"/>
</div>
</div>
</div>
</div>
</t>
</t>
report_controller o dove chiami il report passi realmente un contesto con o, e che o sia l'oggetto corretto (come account.move nel caso delle fatture).Dovresti testare questa versione del template. Se ricevi ulteriori errori, dovresti esaminare i messaggi di errore specifici che Odoo fornisce per diagnosticare ulteriormente il problema.
Traceback (most recent call last): File "<2367>", line 2071, in template_2367 File "<2367>", line 2053, in template_2367_content File "<2367>", line 14, in template_2367_t_call_0 KeyError: 'o'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 120, in report_download response = self.report_routes(reportname, converter=converter, context=context, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xml/controllers/report.py", line 24, in report_routes return super().report_routes( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xlsx_helper/controllers/main.py", line 51, in report_routes return super().report_routes(reportname, docids, converter, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/report_xlsx/controllers/main.py", line 51, in report_routes return super().report_routes(reportname, docids, converter, **data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/http.py", line 722, in route_wrapper result = endpoint(self, *args, **params_ok) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 42, in report_routes pdf = report.with_context(context)._render_qweb_pdf(reportname, docids, data=data)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/mis_builder/report/mis_report_instance_qweb.py", line 27, in _render_qweb_pdf return super()._render_qweb_pdf(report_ref, res_ids, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 61, in _render_qweb_pdf return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 878, in _render_qweb_pdf collected_streams = self._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/sale_pdf_quote_builder/models/ir_actions_report.py", line 17, in _render_qweb_pdf_prepare_streams result = super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 20, in _render_qweb_pdf_prepare_streams return super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 728, in _render_qweb_pdf_prepare_streams html = self.with_context(**additional_context)._render_qweb_html(report_ref, res_ids_wo_stream, data=data)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/odoo/custom_addons/account_financial_report/models/ir_actions_report.py", line 19, in _render_qweb_html return super(IrActionsReport, obj)._render_qweb_html( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 927, in _render_qweb_html return self._render_template(report.report_name, data), 'html' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 654, in _render_template return view_obj._render_template(template, values).encode() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 2050, in _render_template return self.env['ir.qweb']._render(template, values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/tools/profiler.py", line 292, in _tracked_method_render return method_render(self, template, values, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 593, in _render result = ''.join(rendering) ^^^^^^^^^^^^^^^^^^ File "<2346>", line 85, in template_2346 File "<2346>", line 67, in template_2346_content File "<2346>", line 56, in template_2346_t_call_0 File "<2367>", line 2077, in template_2367 odoo.addons.base.models.ir_qweb.QWebException: Error while render the template KeyError: 'o' Template: account.Fattura completa Path: /t/t/t[2] Node:
The above server error caused the following client error: RPC_ERROR: Odoo Server Error at makeErrorFromResponse (http://34.116.160.142/web/assets/debug/web.assets_web.js:27816:19) (/web/static/src/core/network/rpc_service.js:37) at decoder.onload (http://34.116.160.142/web/assets/debug/web.assets_web.js:27699:25) (/web/static/src/core/network/download.js:566)
L'errore KeyError: 'o' che stai riscontrando indica che la chiave o non è presente nel contesto che stai passando al template QWeb. Ciò significa che l'oggetto o che rappresenta la tua fattura (o il documento correlato) non è accessibile quando il template cerca di renderizzarlo.
Verifica il Contesto Passato al Template:
return self.env.ref('your_module.report_template_id').report_action(docids)
docids contenga l'ID della fattura o dell'oggetto di interesse.Controllo della Definizione di o:
o (<t t-set="o" t-value="o.with_context(lang=lang)"/>), verifica che o esista nel contesto. Puoi aggiungere un controllo all'inizio del template per confermare se esiste.<t t-if="not o">
<div>Error: Il contesto 'o' non è disponibile.</div>
</t>
o non è definito.Verifica nei Controller:
Debug in Odoo:
logging per stampare proprio per confermare che l'oggetto o venga passato correttamente.import logging
_logger = logging.getLogger(__name__)
_logger.debug('Context: %s', context)
Controlla i Temi o Altri Moduli:
Sintassi Corretta:
<t t-foreach="lines" t-as="line">
o.Se il problema persiste e non riesci a identificare l'origine, prova ad isolare il problema commentando sezioni del tuo template, così da capire esattamente quale parte genera l'errore.
Se segui questi passi e verifichi cuidadosamente il contesto passato al template, dovresti essere in grado di identificare la causa principale dell'errore e apportare le modifiche necessarie per risolverlo. Se dovessi avere necessità di altro aiuto, non esitare a chiedere!
Not yet included in a published release.