From d59417c879c60c6c124e1a9c638718d22e66880b Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 8 Nov 2012 11:24:23 +0100 Subject: [PATCH 1/3] [IMP] web controllers: add resize option on /web/binary/?image. The max size of resizing is 500*500. bzr revid: chm@openerp.com-20121108102423-oh5633zqlj4g762o --- addons/web/controllers/main.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index ad8d91ed1dd..7f53482619c 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1516,11 +1516,24 @@ class Binary(openerpweb.Controller): try: if not id: res = Model.default_get([field], context).get(field) - image_data = base64.b64decode(res) + image_base64 = res else: res = Model.read([id], [last_update, field], context)[0] retag = hashlib.md5(res.get(last_update)).hexdigest() - image_data = base64.b64decode(res.get(field)) + image_base64 = res.get(field) + + if kw.get('resize'): + resize = kw.get('resize').split(','); + if len(resize) == 2 and int(resize[0]) and int(resize[1]): + width = int(resize[0]) + height = int(resize[1]) + # resize maximum 500*500 + if width > 500: width = 500 + if height > 500: height = 500 + image_base64 = openerp.tools.image_resize_image(base64_source=image_base64, size=(width, height), encoding='base64', filetype='PNG') + + image_data = base64.b64decode(image_base64) + except (TypeError, xmlrpclib.Fault): image_data = self.placeholder(req) headers.append(('ETag', retag)) From 0baf4727ef105ece65f686180ed31e0881c952e3 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 8 Nov 2012 17:23:04 +0100 Subject: [PATCH 2/3] [FIX] followers: no confirm save message bzr revid: chm@openerp.com-20121108162304-paevi0x5isyornd1 --- addons/web/static/src/xml/base.xml | 42 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 215374cb6fb..5cfadc323bd 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1182,26 +1182,28 @@
- -
- - ...Upload in progress... - - - - - - - [ - -
-
- -
- - - -
+ + +
+ + ...Upload in progress... + + + + + + + [ + +
+
+ +
+ + + +
+
From df96456fc56c2c4230535cbd813b8b0a9bd8489b Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 9 Nov 2012 11:21:02 +0100 Subject: [PATCH 3/3] [FIX] view_form: fixing blockUI attribute in multi file uploader bzr revid: chm@openerp.com-20121109102102-o5t86g1jz82175jk --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 906f1d8fe36..82bebb1fe87 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5030,7 +5030,7 @@ instance.web.form.FieldOne2ManyBinaryMultiFiles = instance.web.form.AbstractFiel } // block UI or not - if(this.node.attrs.blockui) { + if(this.node.attrs.blockui>0) { instance.web.blockUI(); } @@ -5064,7 +5064,7 @@ instance.web.form.FieldOne2ManyBinaryMultiFiles = instance.web.form.AbstractFiel }, on_file_loaded: function (event, result) { // unblock UI - if(this.node.attrs.blockui) { + if(this.node.attrs.blockui>0) { instance.web.unblockUI(); }