vaab / report_birt

BIRT Report module for OpenERP
5 stars 6 forks source link

global name 'XmlParser' is not defined #3

Closed sferket closed 11 years ago

sferket commented 11 years ago

We finally found some time to continue this investigation.

After successfully installing the module on v7, including the very useful module report_add_action. We now have the report available in sale.order. After clicking the report we get this error message:

global name 'XmlParser' is not defined

"(, NameError("global name 'XmlParser' is not defined",), )"

Any idea how we can fix this one?

vaab commented 11 years ago

This one is already fixed. There are no more "XmlParser" in all report_birt code. So I'll suggest you to:

1 - check that you've pulled the last code from github by checking your current HEAD commit number which should start with ba96... 2 - delete all *.pyc if any to make sure that there are no dangling links 3 - check that you are actually using this module code and not another one 4 - restart your openerp server as this is python code and it won't get reloaded until you've restarted the server.

I'm out of idea if these steps can't resolve your issue, but I can confirm that this error can NOT come from report_birt last commit code but seems to come from BEFORE last commit code. So I strongly suggest to verify that the last commit code is actually used by your server.

Thanks. Keep me informed of your advancements.

By the way, the full traceback is always welcomed in bug reports and can help me solve issues. So please don't keep it for yourself ;) ... you can often find it in the server's log.

sferket commented 11 years ago

Ok, restarting the server process did the trick.

Now we get:

'NoneType' object has no attribute 'replace'

(<type 'exceptions.AttributeError'>, AttributeError("'NoneType' object has no attribute 'replace'",), <traceback object at 0x7f70d83965a8>) 

The log looks like:

2013-05-23 06:52:22,441 10018 ERROR p100_test_stefaan openerp.service.web_services: Exception: 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/service/web_services.py", line 712, in go
    (result, format) = obj.create(cr, uid, ids, datas, context)
  File "/opt/p100/openerp/open2bizz-addons-7.0/report_birt/birt_report.py", line 126, in create
    return super(BirtProxyFactory, self).create(cr, uid, ids, data, context)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/addons/report_webkit/webkit_report.py", line 332, in create
    return super(WebKitParser, self).create(cursor, uid, ids, data, context)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/report/report_sxw.py", line 444, in create
    fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/report/report_sxw.py", line 513, in create_source_pdf
    return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
  File "/opt/p100/openerp/open2bizz-addons-7.0/report_birt/birt_report.py", line 86, in create_single_pdf
    return super(BirtProxyFactory, self).create_single_pdf(cr, uid, ids, data, report_birt, context=context)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/addons/report_webkit/webkit_report.py", line 208, in create_single_pdf
    return super(WebKitParser,self).create_single_pdf(cursor, uid, ids, data, report_xml, context=context)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/report/report_sxw.py", line 535, in create_single_pdf
    pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8'))
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/report/interface.py", line 205, in create_pdf
    obj = render.rml(rml, localcontext, self.bin_datas, self._get_path(), title)
  File "/opt/openerp/openerp-7.0-20130415-111315/openerp/report/interface.py", line 247, in _get_path
    self.tmpl.replace(os.path.sep, '/').rsplit('/', 1)[0],
AttributeError: 'NoneType' object has no attribute 'replace'
vaab commented 11 years ago

Could you double-check that you've set the report type to "birt" and nothing else (check for spurious spaces, wrong case). Or check that the current report that you are printing is the one you are expecting to print (the one with "birt" type).

This is important, because you can't access line 86 in report_birt/birt_report.py if report's type is set to "birt", and the traceback tells me that you've accessed this line. For some reason, the report's type is thus NOT set to "birt" at this particular point of the code. By the way, the remaining error seems normal since report's type is not "birt", you are in an other report's code which seems to require some particular settings.

I've double checked all by re-installing report_birt on the latest openerp 7.0 code and this work well at the first try provided that you set things correctly to at least use it.

Please make sure also that you have different report services name. This is an OpenERP trick that should be considered seriously: all reports should have distinct service name. Especially the report you are testing should have a unique service name.

Thank you for the traceback it is very helpfull. Next time, you could step even further and try to put it in a quoted block by putting ``` before and after the block so as to put it in a space preserving block (I've edited your comment to do so). You can check what you'll send me via the "Preview" button, which is accessible in the web interface of github you might use to report these issues.

sferket commented 11 years ago

Ok, the problem was related to duplicate service names. Making the service name unique solved this problem.

Thanks.

vaab commented 11 years ago

Happy that this finally works for you. Thanks for your feedbacks, It's precious as it shows that access to reporting system in OpenERP isn't what we could name "straight-forward". If I'll have more time, I might spend it to stuff in some more docs in the README.md.

If you have anything you think you've missed and should have been written in the README.md of report_birt, please feel free to submit a pull request.