How to create Binary Fields:

The first step is to create a new model and than new fields.





Now select an Image. This image store file encoded in base64 in bytea column in your created table.As shown in the above figure.





How to show uploaded images in Qweb Reprots:

Once the images has been uploaded its time to show in qweb reports. For that purpose you have to follow these stpes. The blow code show the xml file for creating qweb reports in odoo. In the file we call our image which one is uploaded from form view of odoo.



<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<report

id="report_example_by_controller"

model="your.model.name"

string="Test"

name="your_module.report_test"

file="your_module.report_example_by_controller"

report_type="qweb-pdf" />

<template id="report_test">

<t t-call="report.html_container">

<div id="picture">

<img t-attf-src="data:image/jpg;base64,{{ your_model_name.binary_field_name }}"

style="width:95px; height:95px;margin-left:55px;"/>

</div>

</t>

</template>

</data>

</openerp>





The below line of code is the key part of showing binary field (image) in qweb reports or your template.





<img t-attf-src="data:image/jpg;base64,{{ your_model_name.binary_field_name }}"

style="width:95px; height:95px;margin-left:55px;"/>





Here "your_model_name" is the name of your model or object for example "(my.model(4,))" , and "binary_field_name" is the name of the "Binary Field" created in odoo model. In our case its "my_images".





The above code will print the images out in the original format, we can change the size of image simply applying by some css. You simply need to call the "t-attf-src" and you can print them out.



