This question has been flagged

I am very new to odoo, I am trying to make a custom report


this part of the xml template

<span t-esc="o.gettotpercep(data['filter'])" />


and this is function

@api.multi def ex_salesvatreport(self): vatcode_ids = self.vatcode_id date_froms = self.date_from date_tos = self.date_to domain = [ ('date_invoice', '>=', date_froms), ('date_invoice', '<=', date_tos) ] invoiceModel = self.env['account.invoice'] invoices = invoiceModel.search(domain) datas = { 'filter': self.vatcode_id._ids, 'ids': invoices._ids, 'model': invoiceModel._name, 'form': invoiceModel.read(), 'context': self._context } print datas #return self.env['report'].get_action(self, 'sales_reports.reportvat', data=datas) return { 'type': 'ir.actions.report.xml', 'report_name': 'sales_reports.reportvat', 'datas': datas } 


this gave me an exception:


UserError: (u'Error to render compiling AST: (<class \'odoo.addons.base.ir.ir_qweb.qweb.QWebException\'>, \'NoneType\' object has no attribute \'__getitem__\'\nTraceback (most recent call last):\n  File "/Users/osvaldo/Desktop/Osvaldo/odoos/odoo/addons/base/ir/ir_qweb/qweb.py", line 315, in _compiled_fn\n    return compiled(self, append, values, options, log)\n  File "<template>", line 1, in template_sales_reports_reportvat_152\n  File "<template>", line 3, in body_call_content_151\n  File "<template>", line 59, in foreach_150\nTypeError: \'NoneType\' object has no attribute \'__getitem__\'\n\nError to render compiling AST\nTypeError: \'NoneType\' object has no attribute \'__getitem__\'\nTemplate: sales_reports.reportvat\nPath: /templates/t/t/div/t/div/div[4]/div[2]/span\nNode: <span t-esc="datas[\'filter\']"/>\n        

Avatar
Discard
Author

I can`t edit, here I put the idented function

@api.multi

def ex_salesvatreport(self):

vatcode_ids = self.vatcode_id

date_froms = self.date_from

date_tos = self.date_to

domain = [

('date_invoice', '>=', date_froms), ('date_invoice', '<=', date_tos)

]

invoiceModel = self.env['account.invoice']

invoices = invoiceModel.search(domain)

datas = {

'filter': self.vatcode_id._ids,

'ids': invoices._ids,

'model': invoiceModel._name,

'form': invoiceModel.read(),

'context': self._context

}

print datas

#return self.env['report'].get_action(self, 'sales_reports.reportvat', data=datas)

return {

'type': 'ir.actions.report.xml',

'report_name': 'sales_reports.reportvat',

'datas': datas

}