3

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>
AnibalAP
  • 43
  • 5
  • I know nothing of QWEB but it looks to me like your line `` is being assigned the empty string, based on this line in the docs: "[if there is no t-value attribute...](https://www.odoo.com/documentation/14.0/reference/qweb.html#setting-variables)" What do you want it to be set to? – xdhmoore Apr 23 '21 at 21:57
  • I am using the term _doc_ to call the fields of the model **fico.respuesta**, specifically of the field _nombre_ – AnibalAP Apr 27 '21 at 17:22
  • The error message seems to be saying that `doc` is of type string, which probably means the t-set line I mentioned isn't working correctly, as far as I can tell. – xdhmoore Apr 27 '21 at 19:18
  • Because `doc` is of type string instead of an object, it doesn't have the `_fields` attribute and so can't use it to look up `doc.nombre`. That's my interpretation, anyway. – xdhmoore Apr 27 '21 at 19:20

0 Answers0