Shridhar Ivani Shridhar Ivani - 1 month ago 11
Python Question

How to generate report in this module odoo i have done this much?

Everythin is working fine but i am not able to get report when i click on print button

In feedback module i have following way of files , feedback_report.xml,hourly_feedback.py,hourly_feedback.xml,__init__.py ,__openerp__.py.Have views folder inside this ,report_hourly.xml

feedback_report.xml has following code .

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="action_hourly_feedback"
string="Hourly Report"
model="hourly.form"
report_type="qweb-pdf"
name="hourly.form.report_hourly"
file="hourly.form.report_hourly"
/>
</data>
</openerp>


hourly_feedback.py has following code

from openerp.osv import fields, osv
from openerp import api
import logging

class hourly_form(osv.Model):
_name = 'hourly.form'
_rec_name = 'assetmodelid_add'
_columns = {

'assetmodelid_add' : fields.many2one('agile.portfolio1','Asset Model Code',),
'folio_num1' : fields.many2one('asset.asset','Folio Num',),
'inspection_name' : fields.many2one('asset1.inspection','Inspection Type'),

}
hourly_form()


hourly_feedback.xml has following code ,

<record model='ir.ui.view' id="hour_event">
<field name="names">hourly.form.form</field>
<field name="model">hourly.form</field>
<field name="arch" type="xml">
<form string="Hours">
<group>

<field name="assetmodelid_add" />
<field name="folio_num1" domain="[('assetmodelid_add', '=', assetmodelid_add)]"/>
<field name="inspection_name" domain="[('assetmodelid_add', '=', assetmodelid_add)]"/>

</group>
</form>
</field>
</record>

<record id="hourly_event_action" model="ir.actions.act_window">
<field name="name">Hourly Form</field>
<field name="res_model">hourly.form</field>
<field name="view_type">form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_creat"> Click here</p>
</field>
</record>

<menuitem id="hourlyfeed_form_creation" name="Hourly Maintainace Form" parent="base.menu_mro_root" />
<menuitem id="hfeed_form_creation" name="Hourly Maintainace Form" parent="hourlyfeed_form_creation" action="hourly_event_action"/>

</data>
</openerp>


openerp.py has following code

{
'name':'Hourly Form',
'version':'1.0',
'description':"""
Feedback Form
""",
'author':'shrihar',
'depends':['base_setup','calendar','Configuration','asset','stock','asset_edit','calander_extended',],
'data':['hourly_feedback.xml','views/report_hourly.xml','feedback_report.xml',],
'demo':[],
'installable':True,
'auto_install':False,
}


In view/report_feedback.xml has following code



<openerp>
<data>
<template id="report_hourly">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<h2>Hour Report</h2>

</div>
</t>
</t>
</t>
</template>
</data>
</openerp>


everything is working fine but i am not able to get report its gettin json error pleas add code

Answer

report_hourly template is defined under views/report_feedback.xml, so you need to add views/report_feedback.xml to data in __openerp__.py.