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

How do I fix a exceptions KeyError in a custom report?

By
AJ Schrafel Paper Corp
on 5/3/13, 3:47 AM 8,956 views

Hello,

I want to create a report that is installable with a custom module I get the following error when I try to print the report.

I created it using the base_report_designer and openoffice. The copy that I uploaded to the server works fine but when I try to run the rml version which I installed using my custom module, i get the following error.

2013-05-03 05:12:01,705 25469 ERROR testDB openerp.service.web_services: Exception: u'report.faxing.fax'
Traceback (most recent call last):
  File "/opt/openerp/server/openerp/service/web_services.py", line 711, in go
    obj = netsvc.LocalService('report.'+object)
  File "/opt/openerp/server/openerp/netsvc.py", line 99, in LocalService
    return Service._services[name]
KeyError: u'report.faxing.fax'
2013-05-03 05:12:01,955 25469 ERROR testDB openerp.netsvc: report.faxing.fax
(<type 'exceptions.KeyError'>, KeyError(u'report.faxing.fax',), <traceback object at 0xb271d20c>)
Traceback (most recent call last):
  File "/opt/openerp/server/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/server/openerp/service/web_services.py", line 654, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/server/openerp/service/web_services.py", line 760, in exp_report_get
    return self._check_report(report_id)
  File "/opt/openerp/server/openerp/service/web_services.py", line 738, in _check_report
    netsvc.abort_response(exc, exc.message, 'warning', exc.traceback)
  File "/opt/openerp/server/openerp/netsvc.py", line 72, in abort_response
    raise openerp.osv.osv.except_osv(description, details)
except_osv: (u'report.faxing.fax', (<type 'exceptions.KeyError'>, KeyError(u'report.faxing.fax',), <traceback object at 0xb271d20c>))

here is the python code adding the report

import time
from openerp.report import report_sxw

class faxing_attach_cover(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(faxing_attach_cover, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
        })
report_sxw.report_sxw(
    'report.faxing.fax',
    'faxing.fax',
    'base_report_to_fax/report/fax_report.rml',
    parser=faxing_attach_cover,
    header="external"
)

here is the XML i use to add the report to the server.

<openerp>
    <data>
        <report
            auto="False"
            id="faxing_faxs"
            model="faxing.fax"
            name="faxing.fax"
            rml="base_report_to_fax/report/fax_report.rml"
            string="Fax Coverpage"
            attachment="(object.state in ('pending')) and ('INV'+(object.name or '').replace('/','')+'.pdf')"
            attachment_use="True"
            usage="default"
            />
    </data>
</openerp>

What am i doing wrong?

1
li
On 8/4/13, 10:27 PM

maybe u just forgot import the report folder in the __init__.py at the root folder of module. i got the silly problem and took me about 2hours to find it.......

yes that was it, i forgot to import the report in _init_.py

AJ Schrafel Paper Corp
on 9/17/13, 1:18 PM
0
Jignesh Rathod (jir)
On 5/8/13, 10:51 AM

Your Error says that give 'name' is wrong in report_sxw.report_sxw('report.faxing.fax', ( PY ) which must be started with report. +(object).

0

Ghanshyam Prajapati

--Ghanshyam Prajapati--
1377
| 4 4 8
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati
On 5/8/13, 11:04 AM

please do following changes in your report.py

replace following code:

report_sxw.report_sxw(
    'report.faxing.fax',
    'faxing.fax',
    'base_report_to_fax/report/fax_report.rml',
    parser=faxing_attach_cover,
    header="external"
)

with

report_sxw.report_sxw(
    'report.faxing_faxs',
    'faxing.fax',
    'base_report_to_fax/report/fax_report.rml',
    parser=faxing_attach_cover,
    header="external"
)

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: 5/3/13, 3:47 AM
Seen: 8956 times
Last updated: 3/16/15, 8:10 AM