Sooo, I try to generate report with action wizard, but I always get "AttributeError: 'ir.ui.menu' object has no attribute 'report_action'" error, this only happen when I try generating report trough a wizard, when I use the print button, it's always working, I already tried following This post, and This post but nothing, I still get the error.
Here's the snippet of my code :
Module name : hotel_promo
Python code
from odoo import models, fields
class hotelreport(models.TransientModel):
_name = 'hotel.report.wizard'
employee = fields.Many2one('res.users', string="Employee")
from_date = fields.Date(string="Starting Date")
to_date = fields.Date(string="Ending Date")
def action_print_report(self):
data = {
'start_date': self.from_date,
'end_date': self.to_date,
'employee': self.employee.id
}
return self.env.ref('hotel_promo.print_report').report_action(self, data=data)
report.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="print_report" model="ir.actions.report">
<field name="name">Hotel Report</field>
<field name="model">hotel.report.wizard</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">hotel_promo.report_hotel</field>
<field name="report_file">hotel_promo.report_hotel</field>
<field name="binding_model_id" ref="model_hotel_report"/>
<field name="binding_type">report</field>
</record>
</odoo>
Report Template
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_hotel">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<t t-foreach="docs" t-as="o">
<div class="page">
<div style="padding-bottom:50px !important;" class="oe_structure"/>
<h2 align="center">Hotel Report</h2>
<table class="table table-condensed">
<tr>
<td>Month</td>
</tr>
<tr>
<td></td>
</tr>
</table>
</div>
</t>
</t>
</t>
</template>
</odoo>
Wizard form
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>
<record id="print_hotel_report" model="ir.ui.view">
<field name="name">Hotel Report</field>
<field name="model">hotel.report.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<group string="Select Employee">
<field name="employee"/>
</group>
<group string="Select Date">
<field name="from_date"/>
<field name="to_date"/>
</group>
<footer>
<button string="Print Report" name="action_print_report" type="object" class="btn-primary"/>
<button string="Discard" class="btn-default" special="cancel"/>
</footer>
</group>
</form>
</field>
</record>
</data>
</odoo>