RML based reporting broken for addons with images outside root_path

Bug #781967 reported by Equipo OPENTIA (http://www.opentia.com)
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Low
OpenERP's Framework R&D

Bug Description

Currently, in order to be found by OpenERP, image elements within RML templates must be specified making use of paths relative to 'root_path'. With the 'addons_path' functionality, this behaviour becomes inconsistent; if an addon is moved to a valid directory outside the 'root_path' directory, the reporting process is broken and the server raises an IOError exception.

To deal with this problem, the RML template must contain the full path to the image file (which can be anything but flexible), or make use of a custom tag to set up the path dynamically.

Attached is a patch that enables the server to recognise image elements with paths relative to the module directory, regardless of the addons directory where it is. I.e.:

    <image file="my_addon/images/my_report_image.png" x="0" y="0"/>

Related branches

Revision history for this message
Equipo OPENTIA (http://www.opentia.com) (opentia) wrote :
Revision history for this message
xrg (xrg) wrote : Re: [Bug 781967] [NEW] RML based reporting broken for addons with images outside root_path

On Friday 13 May 2011, you wrote:
> Public bug reported:
>
> Currently, in order to be found by OpenERP, image elements within RML
> templates must be specified making use of paths relative to 'root_path'.
> With the 'addons_path'...

I think the functionality you describe is already there. You see, in
_open_image(filename, path=..) the 'path' parameter serves exactly that
purpose. It should contain root_path, addons paths etc. I remember having
tested that with the 'test_orm' module.

In addition, reference to configuration settings from trml2pdf is not
advisable. We want to keep that file as agnostic of the other server's API as
possible.

You are talking about v6.0, aren't you?

--
Say NO to spam and viruses. Stop using Microsoft Windows!

Revision history for this message
Equipo OPENTIA (http://www.opentia.com) (opentia) wrote :

Using the 6.0 branch here, on Debian wheeze/sid and on squeeze, with Python 2.6.6.

Thanks xrg. You are right, it's not the right place to add modifications to the path. It's the _get_path() method, in the 'report_rml' who should include the additional 'addons_path' directories.

In this case it's more clear, since the image element just needs the name of the file put in the same directory than the RML template file:

       <image file="my_report_image.png" x="0" y="0"/>

Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Low
status: New → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello Equipo OPENTIA,

Thanks for patch and Thanks for reporting,

It has been fixed in lp:~openerp-dev/openobject-server/trunk-bug-781967-ysa branch.
Revision No:- 3424
Revision ID: <email address hidden> and It will be merged soon
with the trunk server.

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

FYI, here is the comment I put on the merge proposal (and the reason I put back the report to confirmed):

I think it is unnecessary to add things in _get_path: eventually the function file_open in openerp/tools/misc.py will be called (via _open_image in openerp/report/render/rml2pdf/trml2pdf.py) and that function is using the addons_path info.

Changed in openobject-server:
status: Fix Committed → Confirmed
Changed in openobject-server:
status: Confirmed → In Progress
Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello,

It has been fixed in lp:~openerp-dev/openobject-server/trunk-bug-781967-ysa
Rev no:- 3425

Thanks,

Changed in openobject-server:
status: In Progress → Fix Committed
Revision history for this message
Vo Minh Thu (thu) wrote :

Equipo OPENTIA:

Does adding the 'addons' in the paths returned by _get_path in openerp/report/interface.py do the trick?

Otherwise, you can simply put the image in the same directory than the report itself (and the path to the file is just the bare filename).

=== modified file 'openerp/report/interface.py'
--- openerp/report/interface.py 2011-04-20 15:27:18 +0000
+++ openerp/report/interface.py 2011-06-29 15:34:06 +0000
@@ -233,6 +233,7 @@
     def _get_path(self):
         ret = []
         ret.append(self.tmpl.replace(os.path.sep, '/').rsplit('/',1)[0]) # Same dir as the report rml
+ ret.append('addons')
         ret.append(tools.config['root_path'])
         return ret

Revision history for this message
Yogesh (SerpentCS) (yogesh-serpentcs) wrote :

Hello Vo Minh Thu,

Thanks for your feedback.

I apply patch given by you in #7 and checked the scenario if I set image path account/images/accounting.png then solved the problem and working fine but if I set image path addons/account/images/accounting.png then generate the error(image path not found).

Thanks,

Revision history for this message
Vo Minh Thu (thu) wrote :

Yogesh,

Since you say the problem is solved with the above change, I will apply it in trunk and close this bug.

Setting a path with 'addons' in it isn't a good idea: the name of that directory can change from one configuration to another. The whole point of using '<addon-name>/path/to/the/file.png' is to be free of the addons directory name.

Revision history for this message
Vo Minh Thu (thu) wrote :

Fixed in trunk.
revno: 3595
revision-id: <email address hidden>

Changed in openobject-server:
status: Fix Committed → Fix Released
Revision history for this message
Paul Giancarlo Diaz Velasco (paulgiancarlod) wrote :

i have this patch, but when i run the migrate script, stills hapen

python migrate.py --config=/etc/openerp-server.conf --database=mydatabase --run-migrations=6.0

the result>

sh: 1: git: not found
copying database mydatabase to mydatabase_migrated...
Copying the database using 'with template'
running migration for 6.0
ERROR: couldn't create the logfile directory. Logging to the standard output.
[2015-07-08 15:43:49,595][?] INFO:server:OpenERP version - 6.0.4
[2015-07-08 15:43:49,596][?] INFO:server:addons_path - /var/tmp/openupgrade/6.0/server/bin/addons,/var/tmp/openupgrade/6.0/addons/
[2015-07-08 15:43:49,596][?] INFO:server:database hostname - localhost
[2015-07-08 15:43:49,596][?] INFO:server:database port - 5432
[2015-07-08 15:43:49,596][?] INFO:server:database user - openerp5
[2015-07-08 15:43:49,596][?] INFO:server:initialising distributed objects services
Traceback (most recent call last):
  File "/var/tmp/openupgrade/6.0/server/bin/openerp-server.py", line 94, in <module>
    import report
  File "/var/tmp/openupgrade/6.0/server/bin/report/__init__.py", line 22, in <module>
    import interface
  File "/var/tmp/openupgrade/6.0/server/bin/report/interface.py", line 30, in <module>
    import addons
ImportError: No module named addons

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.