I am making a report by QWEB in Odoo 12, it only has to take the fields of a model called fico.respuesta, the report is printed without any problem, however, when calling the fields of the model it generates the aforementioned error:
Error to render compiling AST
AttributeError: 'str' object has no attribute '_fields'
Template: f360_circulo_credito.report_cdc_document
Path: /templates/t/t/div/div[3]/table/tbody/tr/td[1]/span
Node: <span t-field="doc.nombre"/>
Below I attach the model code:
class FICORespuesta(models.Model):
_name = 'fico.respuesta'
_description = 'CdC Fico Respuesta'
#CAMPO ID
partner_id = fields.Char('Partner id')
#DATOS ID
folio = fields.Char(string='Folio')
nombre = fields.Char(string='Nombre')
rfc = fields.Char(string='RFC')
The report code is nothing more than an xml template called f360_report_fico_template.xml, so far I have not called more fields other than the name field
Annex the template code.
I apologize for the bad indentation, in Visual Studio it does not look this way.
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_cdc_document">
<t t-call="web.external_layout">
<t t-set="doc" />
<!-- t-value="doc.with_context(lang=doc.partner_id.lang)" -->
<style>
table {
width:100%;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
font-family:verdana;
}
th, td {
padding: 5px;
text-align: left;
}
#t01 tr:nth-child(even) {
background-color: #eee;
}
#t01 tr:nth-child(odd) {
background-color: #fff;
}
#t01 th {
background-color: grey;
color: white;
}
</style>
<div class="page">
<div class="oe_structure"/>
<h2 class="text-center" style="font-size:24px;font-family:verdana;" color="teal">
<table>
<tbody>
<tr>
<td><h2 style="font-size:24px" color="teal">Reporte de Crédito: FICO Score</h2></td>
</tr>
</tbody>
</table>
</h2>
<div class="col-auto mw-100 mb-2" style="font-size:20px; color:grey; font-family:verdana;">
<strong>Datos Generales</strong>
</div>
<div>
<table id="t01">
<thead>
<tr>
<t t-set="colspan" t-value="3"/>
<th class="text-left" scope="col" style="width:350px">Nombre</th>
<th class="text-left" scope="col" style="width:350px">RFC</th>
<th class="text-left" scope="col" style="width:350px">Folio</th>
</tr>
</thead>
<tbody>
<tr>
<td><span t-field="doc.nombre"/></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="col-auto mw-100 mb-2" style="font-size:20px; color:grey; font-family:verdana;">
<strong>Datos del reporte:</strong>
</div>
<div>
<table id="t01">
<thead>
<tr>
<t t-set="colspan" t-value="4"/>
<th class="text-left" scope="col" style="width:350px">Apellido Paterno</th>
<th class="text-left" scope="col" style="width:350px">Apellido Materno</th>
<th class="text-left" scope="col" style="width:350px">Nombre</th>
<th class="text-left" scope="col" style="width:350px">Fecha de Nacimiento</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="oe_structure"/>
</div>
</t>
</template>
<template id="report_cdc_fico">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="f360_circulo_credito.report_cdc_document" />
<!-- t-lang="doc.partner_id.lang" -->
</t>
</t>
</template>
</odoo>