Skip to content

Error using account.move.send.wizard : KeyError: 'is_refund' #553

@mauro2306

Description

@mauro2306

Using Odoo 18 in a docker environment, i got an issue when trying to execute a refund (Extourner in french not sure in English) that neither generating the PDF or a Peppol would work and ended up with this exception :

Erreur de serveur Odoo
RPC_ERROR

Odoo Server Error

Occured on odoo.xxx.xxx on model account.move.send.wizard on 2025-07-24 16:03:46 GMT

Traceback (most recent call last):
  File "<717>", line 2565, in template_717
  File "<717>", line 2547, in template_717_content
  File "<717>", line 1719, in template_717_t_call_0
KeyError: 'is_refund'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2123, in _transactioning
    return service_model.retrying(func, env=self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 156, in retrying
    result = func()
             ^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2090, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 2338, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 754, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 42, in call_button
    action = call_kw(request.env[model], method, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 533, in call_kw
    result = getattr(recs, name)(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/account_peppol/wizard/account_move_send_wizard.py", line 59, in action_send_and_print
    return super().action_send_and_print(allow_fallback_pdf=allow_fallback_pdf)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/account/wizard/account_move_send_wizard.py", line 294, in action_send_and_print
    attachments = self._generate_and_send_invoices(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/account/models/account_move_send.py", line 716, in _generate_and_send_invoices
    self._generate_invoice_documents(moves_data, allow_fallback_pdf=allow_fallback_pdf)
  File "/usr/lib/python3/dist-packages/odoo/addons/account/models/account_move_send.py", line 641, in _generate_invoice_documents
    self._prepare_invoice_pdf_report(batch)
  File "/usr/lib/python3/dist-packages/odoo/addons/account/models/account_move_send.py", line 354, in _prepare_invoice_pdf_report
    content, report_type = self.env['ir.actions.report'].with_company(company_id)._pre_render_qweb_pdf(pdf_report.report_name, res_ids=ids)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 75, in _pre_render_qweb_pdf
    return super()._pre_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 1003, in _pre_render_qweb_pdf
    return self._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids), 'pdf'
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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_edi_ubl_cii/models/ir_actions_report.py", line 11, in _render_qweb_pdf_prepare_streams
    collected_streams = super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 22, 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 853, in _render_qweb_pdf_prepare_streams
    html = self.with_context(**additional_context)._render_qweb_html(report_ref, all_res_ids_wo_stream, data=data)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 1091, 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 769, 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 2199, in _render_template
    return self.env['ir.qweb']._render(template, values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/odoo/tools/profiler.py", line 313, 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 606, in _render
    result = ''.join(rendering)
             ^^^^^^^^^^^^^^^^^^
  File "<723>", line 38, in template_723
  File "<723>", line 27, in template_723_content
  File "<722>", line 86, in template_722
  File "<722>", line 68, in template_722_content
  File "<722>", line 56, in template_722_t_call_0
  File "<717>", line 2573, in template_717
odoo.addons.base.models.ir_qweb.QWebException: Error while render the template
KeyError: 'is_refund'
Template: account.report_invoice_document
Path: /t/t/div[2]/div/div[4]/div[1]/div[1]/div/table/t[2]/t/t[2]/tr/td[1]/i/t[1]
Node: <t t-if="payment_vals[\'is_refund\']"/>

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPCError@https://odoo.xxx.xxx/web/assets/74fbd7f/web.assets_web.min.js:3145:338
    makeErrorFromResponse@https://odoo.xxx.xxx/web/assets/74fbd7f/web.assets_web.min.js:3148:163
    rpc._rpc/promise</<@https://odoo.xxx.xxx/web/assets/74fbd7f/web.assets_web.min.js:3153:34
    `

I fixed the issue modifying in the view "report_invoice_document" the line 196 the following
<t t-if="payment_vals['is_refund']">Reversed on </t>

by

<t t-if="payment_vals.get('is_refund', False)">Reversed on </t>

and it resolved my problem.
Of course this is a temporary fix, with the help from Claude as i am not a developer :-) and i know this file would be overwritten once an update will be deploy, so i am posting the issue in the hope this next version would come with a tested and properly done fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions