Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
4863 Lượt xem

Here is the code I am using for the table inside the Partner Ledger that I need the invoice due date on. The underlined section is what I was trying to use to get the due date but I am getting back an error. Can anyone help with the correct attribute?

<tbody style="border: 1px solid black">

                            <tr t-foreach="lines(data, o)" t-as="line">

                                <td style="border-left: 1 px solid black">

                                    <span t-esc="line['date']"/>

                                </td>

                                <td style="border-left:1px solid black">

                                    <span t-esc="line['date_maturity'}"/>

                                </td>

                                <td style="border-left: 1 px solid black">

                                    <span t-esc="line['displayed_name']"/>

                                </td>

                                <td style="border-left: 1 px solid black">

                                    <span t-esc="line['name']"/>

                                </td>

                                <td style="border-left: 1 px solid black" class="text-right">

                                    <span t-esc="line['debit']" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>

                                </td>

                                <td style="border-left: 1 px solid black" class="text-right">

                                    <span t-esc="line['credit']" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>

                                </td>

                                <td style="border-left: 1 px solid black" class="text-right">

                                    <span t-esc="line['progress']" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>

                                </td>

                                <td class="text-right" t-if="data['form']['amount_currency']">

                                    <t t-if="line['currency_id']">

                                        <span t-esc="line['amount_currency']" t-options="{'widget': 'monetary', 'display_currency': line['currency_id']}"/>

                                    </t>

                                </td>

                            </tr>

                        </tbody>

Ảnh đại diện
Huỷ bỏ

Can you please check "lines(data, o)" function. or publish here.

Câu trả lời hay nhất

Do you really have it formatted this way:

<span t-esc="line['date_maturity'}"/>

The opening and closing brackets are different.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Ray,
Thanks for spotting that typo, but it still doesn't solve the issue. This is the error I receive:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_qweb/qweb.py", line 342, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_848_9985
  File "<template>", line 2, in body_call_content_9984
  File "<template>", line 6, in foreach_9983
  File "<template>", line 7, in body_call_content_9982
  File "<template>", line 50, in foreach_9968
KeyError: 'date_maturity'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odoo/src/odoo/11.0/addons/web/controllers/main.py", line 1624, in report_download
    response = self.report_routes(reportname, converter='pdf', **dict(data))
  File "/home/odoo/src/odoo/11.0/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/home/odoo/src/odoo/11.0/addons/web/controllers/main.py", line 1569, in report_routes
    pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_actions_report.py", line 628, in render_qweb_pdf
    html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
  File "/home/odoo/src/enterprise/11.0/web_studio/models/report.py", line 17, in render_qweb_html
    return super(Report, self).render_qweb_html(docids, data)
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_actions_report.py", line 666, in render_qweb_html
    return self.render_template(self.report_name, data), 'html'
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_actions_report.py", line 470, in render_template
    return view_obj.render_template(template, values)
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_ui_view.py", line 1195, in render_template
    return self.browse(self.get_view_id(template)).render(values, engine)
  File "/home/odoo/src/odoo/11.0/addons/website/models/ir_ui_view.py", line 113, in render
    return super(View, self).render(values, engine=engine)
  File "/home/odoo/src/odoo/11.0/addons/web_editor/models/ir_ui_view.py", line 27, in render
    return super(IrUiView, self).render(values=values, engine=engine)
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_ui_view.py", line 1204, in render
    return self.env[engine].render(self.id, qcontext)
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 57, in render
    return super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_qweb/qweb.py", line 271, in render
    self.compile(template, options)(self, body.append, values or {})
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_qweb/qweb.py", line 349, in _compiled_fn
    raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name)
odoo.addons.base.ir.ir_qweb.qweb.QWebException: 'date_maturity'
Traceback (most recent call last):
  File "/home/odoo/src/odoo/11.0/odoo/addons/base/ir/ir_qweb/qweb.py", line 342, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "<template>", line 1, in template_848_9985
  File "<template>", line 2, in body_call_content_9984
  File "<template>", line 6, in foreach_9983
  File "<template>", line 7, in body_call_content_9982
  File "<template>", line 50, in foreach_9968
KeyError: 'date_maturity'

Error to render compiling AST
KeyError: 'date_maturity'
Template: 848
Path: /templates/t/t/t[4]/t/div[1]/table/tbody/tr/td[2]/span
Node: <span t-esc="line['date_maturity']"/>


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

cameron,

Close the bracket in proper format.

<span t-esc="line['date_maturity']"/>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 23
2122
1
thg 2 20
3310
1
thg 2 17
9414
1
thg 2 16
6039
1
thg 3 15
4857