[IMP] don't duplicate website_url function field of attachments
authorXavier Morel <xmo@openerp.com>
Mon, 3 Mar 2014 14:24:01 +0000 (15:24 +0100)
committerXavier Morel <xmo@openerp.com>
Mon, 3 Mar 2014 14:24:01 +0000 (15:24 +0100)
bzr revid: xmo@openerp.com-20140303142401-2jaxc3m31tmqw9qa

addons/website/controllers/main.py

index 6053150..856ab6e 100644 (file)
@@ -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)