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

Đang mở
#553 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
docker, python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với view account.report_invoice_document quanh dòng 196 và lần theo các giá trị thanh toán được truyền từ account_move_send_wizard.action_send_and_print. Tái hiện việc tạo PDF hoàn tiền và Peppol, sau đó xác minh rằng báo cáo được kết xuất mà không có KeyError đối với cả các khoản thanh toán hoàn tiền và không hoàn tiền.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Dockerfile
Star
1.2k
Fork
1.7k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của odoo/docker

Tất cả issue của odoo/docker

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.