Loading an image into Odoo
I am trying to add an o shaped widget to odoo screeen,
I have used a field as shown below,
image = fields.Binary("Image", attachment=True,
help="This field holds the image used as avatar for \
this contact, limited to 1024x1024px",)
XML:
<field name="image" widget='image' class="oe_avatar"/>
The loaded image has free space around the image, how do I load the image as it is without adding space around the image?
+3
source to share
1 answer
Here's a subtle snippet of code where I saved an image to be used in the QWeb report.
from openerp import api, fields, models, tools
class ResPartner(models.Model):
_inherit = "res.partner"
partner_report_image = fields.Binary(string='Report image', compute='_get_image')
@api.multi
@api.depends('image')
def _get_image(self):
for rec in self:
rec.partner_report_image = tools.image_resize_image_medium(
rec.image, size=(500, 500))
You should check out openerp / tools / image.py , it has some pretty neat image processing functions. Hope this helps!
+1
source to share