Hello,
I am trying to display form fields in report but following error occur.
Error:
odoo.addons.base.ir.ir_qweb.qweb.QWebException: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "/usr/local/sampada/eclipse-workspace/odoo11/odoo/addons/base/ir/ir_qweb/qweb.py", line 343, in _compiled_fn
return compiled(self, append, new, options, log)
File "<template>", line 1, in template_1018_120
File "<template>", line 2, in body_call_content_119
File "<template>", line 3, in body_call_content_118
TypeError: 'NoneType' object is not subscriptable
Error to render compiling AST
TypeError: 'NoneType' object is not subscriptable
Template: 1018
Path: /templates/t/t/t/div/t[1]
Node: <t t-if="data['form_date']"><span t-esc="data['from_date']">From Date:</span></t>
.py file
from odoo import models, fields, api
class DataForReport(models.AbstractModel):
_name = 'report.survey_client.pl_report_template'#for report name must be 'report.module_name.template_id_of_report'
@api.multi
def get_Form_data(self, docid, data):
model_data = data['form']
return self.report_calculations(model_data)
@api.model
def report_calculations(self,data):
from_date = data['from_date']
to_date = data['to_date']
product_id = data['product_id']
template file:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<template id="pl_report_template_struct">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<center><span><strong><h2>Product Profit Loss</h2></strong></span></center>
<t t-if="data['form_date']"><span t-esc="data['from_date']">From Date:</span></t>
<t t-if="data['to_date']"><span t-esc="data['from_date']">To Date:</span></t>
<t t-if="data['product_id']"><span t-esc="data['product_id']">Product:</span></t>
</div>
</t>
</t>
</template>
</data>
</odoo>
Report File
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<report
id="pl_report_def"
string="Product Profit Loss"
model="form.data"
report_type="qweb-html"
file="survey_client.pl_report_template_struct"
name="survey_client.pl_report_template_struct"
/>
</data>
</odoo>
I have try all solution from internet but same error will occur.any Please help.
Better to the report development from odoo documentation. https://www.odoo.com/documentation/10.0/reference/reports.html
*learn
Thanks @Hilar AK for your help it's working.