Using Odoo 12 I'm trying to resize file uploads as they are attached to the crm_lead model.
When I visit my website and use my custom form that generates leads to upload a file it doesn't seem to be resized though.
My code is included below, any ideas why it isn't working?
from odoo import api, models import logging _logger = logging.getLogger(__name__) class Lead(models.Model): _inherit = 'crm.lead' @api.model def create(self,values): _logger.info(values) record = super(Lead, self).create(values) if 'image' in values: resize_image = tools.image_resize_image(values['image'], size=(2048, 2048), avoid_if_small=True) record['image'] = resize_image return record @api.multi def write(self, values): _logger.info(values) record super(Lead, self).write(values) if 'image' in values: resize_image = tools.image_resize_image(values['image'], size=(2048, 2048), avoid_if_small=True) record['image'] = resize_image return record