Skip to Content
Menu
This question has been flagged
2698 Views

Hi, I'm generating an xlsx report by using the report_xlsx module from OCA but , when I added a Many2one field record to print in the report, Odoo sent me back this error

raise TypeError("Unsupported type %s in write()" % type(token))
TypeError: Unsupported type in write()

These are the main parts of my python file for the report, stored in Report folder:

from odoo import models, api
class SchedaDipendenteXlsx(models.AbstractModel):
_name = 'report.piani_formazione.report_schede_dipendenti_xlsx'
_inherit = 'report . report _ xlsx . abstract'

def generate_xlsx_report(self, workbook, data, dipendente):
   sheet = workbook.add_worksheet('Schede dei dipendenti')
   bold = workbook.add_format({'bold': True})
   row = 0
   col = 0
   for obj in dipendente:
     if row == 0:
       sheet.write(0, 0, obj.dipendente_azienda, bold)
     row += 1
     [...]

This are the main parts of the python file of the model from which I print the report, stored in Models folder:

from odoo import models, fields, api
class Dipendente(models.Model):
_name = 'piani_formazione.dipendente'
_rec_name = 'codice_fiscale'
codice_fiscale = fields.Char(string="Codice Fiscale", size=16, required=True)
dipendente_azienda = fields.Many2one('piani_formazione.azienda', string='Azienda', required=True) 

And these are main parts of the python file of the model which I refer to in the Many2one field:

from odoo import models, fields, api
class Azienda(models.Model):
_name = 'piani_formazione.azienda'
_rec_name = 'nome'
nome = fields.Text(string="Azienda", required=True)
azienda_lista_dipendenti = fields.One2many('piani_formazione.dipendente','dipendente_azienda',string="Dipendenti dell'azienda")
Avatar
Discard