osiell / oerplib

OERPLib is a Python RPC library which aims to provide an easy way to remotely pilot and manage an OpenERP server.
GNU Lesser General Public License v3.0
21 stars 20 forks source link

Error while creating report on OpenERP 7.0 with multiple workers #3

Closed sebalix closed 10 years ago

sebalix commented 10 years ago

Original report : https://bugs.launchpad.net/oerplib/+bug/1371790

Oerplib fails to generate reports when OpenERP 7.0 is running in multi-process mode using 'workers=N'.

Steps to reproduce:

  1. make sure that workers = N (where N > 0) is in openerp-server.conf
  2. Create a new database with demo data enabled
  3. install 'warehouse' and 'sale' modules. These modules will create demo sale order
  4. Use the following snippet to see the error:
import oerplib

oerp = oerplib.OERP(server='localhost', database='test', version='7.0')
oerp.login(user='admin', passwd='test')

print oerp.report('sale.order', 'sale.sale', [8])

The following error is produced:

Traceback (most recent call last):
  File "/home/etsinko/work/PyqtTest/pyqt/widgets/test.py", line 7, in <module>
    print oerp.report('sale.order', 'sale.sale', [8])
  File "/usr/local/lib/python2.7/dist-packages/oerplib/oerp.py", line 317, in report
    report_type, context)
  File "/usr/local/lib/python2.7/dist-packages/oerplib/oerp.py", line 347, in _get_report_data
    raise error.RPCError("Unknown error occurred during the "
oerplib.error.RPCError: Unknown error occurred during the download of the report.
  1. If you set workers = 0 in openerp-server.conf the snippet prints out the name of the temporary file in which report is contained
etsinko commented 10 years ago

Sebastien, Do you still need a server log? I can post it if you need it.

sebalix commented 10 years ago

No it's fine, thank you. The fix is ready, just some tests remaining and I will push it (maybe tonight). Thanks!

etsinko commented 10 years ago

Thank you Sebastien, Maybe it is too late since the fix is ready but I realized that the issue was with OerpLib connecting again to OpenERP server to download the report, while OpenERP server used a new worker process to do that.

sebalix commented 10 years ago

Yes, this is exactly that. In fact, with OpenERP 5.0 and 6.0, the server was providing two methods to download reports: report and report_get. The first orders to the server to build a report, and the second must be called regularly to check if the report is ready to be downloaded. Multiprocess/workers appeared in OpenERP 6.1, and since the memory is not shared between two processes/requests... report_get has no clue about the report ordered by report I think. For this purpose OpenERP added the render_report RPC method, but OERPLib was not aware of it.

etsinko commented 10 years ago

Yes, I stumbled onto render_report method but I couldn't find any documentation about it.

sebalix commented 10 years ago

You can pull the develop branch if you want (it is stable enough). I will make a release later, there are some other stuff I need to check since the GitHub migration.