Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

When i click on Print Button RML get error

By
Harsh Dhaduk
on 3/31/14, 10:49 AM 1,821 views

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")
1

Jagdish Panchal

--Jagdish Panchal--
2674
| 5 3 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 4/1/14, 2:49 AM

Hi,

import report in your main 1) __init__.py file

Hope this will help you

i tried but same error come report.hd.wizard type 'exceptions.KeyError', KeyError(u'report.hd.wizard', traceback object at 0xc9b6b44

Harsh Dhaduk
on 4/1/14, 6:34 AM

Try this: report_sxw.report_sxw('report.hd.report', 'hd.wizard', 'addons/hd_report/report/hd_report.rml', parser = hd_report,header="external")

Jagdish Panchal
on 4/1/14, 6:38 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 3/31/14, 10:49 AM
Seen: 1821 times
Last updated: 3/16/15, 8:10 AM