Hello, Friends
i created one module testing purpose to generate blank pdf file to open. but something i missed and when i press print button then error come
so can you help me how can i fix.
Thanks In Advance
Error Come Like This
report.hd.wizard
type 'exceptions.KeyError', KeyError(u'report.hd.wizard', traceback object at 0xc9b6b44
directory structure like this
hd_report
- __init__.py
- __openerp__.py
- hd_wizard.py
- hd_wizard_view.xml
- report 1.__init__.py 2.hd_report.py 3.hd_report.rml 4.hd_r
eport.sxw
1)__init__.py
import hd_wizard
2)__openerp__.py
{
'name': 'HD Report Wizard',
'version': '1.0',
'category': 'General',
'author': 'Harsh Dhaduk',
'depends': ['sale', 'point_of_sale'],
'data': [ "hd_wizard_view.xml" ],
'installable': True,
'active': False,
}
3)hd_wizard.py
from openerp.osv import fields, osv from openerp.tools.translate import _ import time
class hd_wizard(osv.osv_memory): _name = "hd.wizard" def get_start_date(self, cr, uid, context=None): start_date = time.strftime('%Y') + '-01-01' return start_date _columns = { 'start_date': fields.date('Start Date',
required=True), 'end_date': fields.date('End Date', required=True), 'all_shops': fields.boolean('All Shops'), 'shop_ids': fields.many2many('sale.shop', 'rel_wizard_shop', 'wizard_id', 'shop_id', 'Shops'), } _defaults = { 'start_date': get_start_date, 'end_date': time.strftime('%Y-%m-%d'), }
def print_report(self, cr, uid, ids, context=None): record = self.read(cr, uid, ids[0], context=context) datas = { 'model': 'hd.wizard', 'ids': ids, 'form': record, } return { 'type': 'ir.actions.report.xml', 'report_name': 'hd.wizard', 'datas': datas, 'nodestroy': True } hd_wizard()
4) hd_wizard_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_hd_wizard_form" model="ir.ui.view">
<field name="name">view.hd.wizard.form</field>
<field name="model">hd.wizard</field>
<field name="arch" type="xml">
<form string="HD Report Wizard" version="7.0">
<group col="4" colspan="4">
<field name="start_date"/>
<field name="end_date"/>
</group>
<group col="4" colspan="4">
<field name="all_shops"/>
</group>
<group colspan="4">
<field name="shop_ids" nolabel="1" attrs="{'readonly': [('all_shops', '=', True)]}"/>
</group>
<footer>
<button name="print_report" string="Print" type="object" class="oe_highlight"/>
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_hd_wizard" model="ir.actions.act_window">
<field name="name">HD Wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">hd.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="view_id" ref="view_hd_wizard_form"/>
</record>
<menuitem action="action_hd_wizard" id="menu_hd_wizard"
parent="base.next_id_64"/>
<report
auto="False"
id="hd_report_custome"
model="hd.wizard"
name="hd.report"
rml="hd_report/report/hd_report.rml"
string="Custome Report ..."
header="False"/>
</data>
</openerp>
5)report->__init__.py
import hd_report
6)report->hd_report.py
import time
from common_report_header import common_report_header
from openerp.report import report_sxw
class hd_report(report_sxw.rml_parse, common_report_header):
def __init__(self, cr, uid, name, context):
super(hd_report, self).__init__(cr, uid, name, context)
self.localcontext.update({
})
report_sxw.report_sxw('hd.report', 'hd.wizard', 'addons/hd_report/report/hd_report.rml', parser = hd_report,header="external")