Search code examples
reportodoorml

how to add static image to odoo report using rml


I am trying to add some static images to odoo report but it doesn't work for me, I tried to test using existing logo image from installed web module but it doesn't work. This my code :

<image x="1.3cm" y="27.7cm" height="40.0" file="/web/static/src/img/logo.png"></image>

when I try to generate a report, it shows a pop-up error :

type 'exceptions.IOError File /web/static/src/img/logo.png cannot be found in image path handle_pageBegin args=() traceback object at 0x2627DEE0>

I am not sure what's wrong, is there another way to access image files?

Edit: I was following this answer from Odoo official forum: https://www.odoo.com/fr_FR/forum/help-1/question/print-image-in-rml-file-24663


Solution

  • the path was simply wrong.. the working path is the server directory so if you want to use file or image from other modules Solution 1 : you just add "addons/$module_directory_name" to my file path.. in my case addons/web

    file="addons/[module_name]/[image_name.image_format]"
    

    example :

    file="addons/web/static/src/img/logo.png"
    

    Solution 2 :

    file="http://[server]:[port]/[module_name]/[image_name.image_format]"
    

    example :

    file="http://localhost:8069/web/static/src/img/logo.png"