From ec68d3d8bd13e84cd742e849c4ac602805a5d4c3 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Mon, 3 Mar 2014 15:24:01 +0100 Subject: [PATCH] [IMP] don't duplicate website_url function field of attachments bzr revid: xmo@openerp.com-20140303142401-2jaxc3m31tmqw9qa --- addons/website/controllers/main.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 605315050c6..856ab6ecffc 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -259,20 +259,18 @@ class Website(openerp.addons.web.controllers.main.Home): u"Image size excessive, uploaded images must be smaller " u"than 42 million pixel") - attachment_id = request.registry['ir.attachment'].create(request.cr, request.uid, { + Attachments = request.registry['ir.attachment'] + attachment_id = Attachments.create(request.cr, request.uid, { 'name': upload.filename, 'datas': image_data.encode('base64'), 'datas_fname': upload.filename, 'res_model': 'ir.ui.view', }, request.context) - url = website.urlplus('/website/image', { - 'model': 'ir.attachment', - 'id': attachment_id, - 'field': 'datas', - 'max_height': MAX_IMAGE_HEIGHT, - 'max_width': MAX_IMAGE_WIDTH, - }) + [attachment] = Attachments.read( + request.cr, request.uid, [attachment_id], ['website_url'], + context=request.context) + url = attachment['website_url'] except Exception, e: logger.exception("Failed to upload image to attachment") message = unicode(e)