From 1942522969753e29ace00125e9f6186f66905588 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 23 Jun 2015 11:46:20 +0200 Subject: [PATCH 1/2] [FIX] base: update File Content for binary field To distinguish two ir.attachment 'File Content', we base it on the file size (this I imagine is for efficiency). This is done by setting bin_size in the context. Doing this, the returned db_datas field will be the file size of the converted to base64 content (if no filestore). But this size is returned in string format, so "get_nice_size" (in openerp/osv/fields.py) which gets this size calculates the length of the string. e.g: if the size is '2142' get_nice_size will return 4. This fix solves this by converting the string to an integer, thus unifying it with the filestore case (where we use os.path.getsize which return an integer). Also, the field presenting the issue (FieldBinaryFile) has been changed so it is always updated even if the size is the same (as it was already done by 3632949 for FieldBinaryImage widget). closes #7223 opw-643071 --- addons/web/static/src/js/view_form.js | 11 +++++++++++ openerp/addons/base/ir/ir_attachment.py | 3 +++ 2 files changed, 14 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 83faa5e8626..9172df0efe4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -5177,6 +5177,17 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({ this._super.apply(this, arguments); this.$el.find('input').eq(0).val(''); this.set_filename(''); + }, + set_value: function(value_){ + var changed = value_ !== this.get_value(); + this._super.apply(this, arguments); + // Trigger value change if size is the same + if (!changed){ + this.trigger("change:value", this, { + oldValue: value_, + newValue: value_ + }); + } } }); diff --git a/openerp/addons/base/ir/ir_attachment.py b/openerp/addons/base/ir/ir_attachment.py index 73bf8c94b43..97edffd6ada 100644 --- a/openerp/addons/base/ir/ir_attachment.py +++ b/openerp/addons/base/ir/ir_attachment.py @@ -132,6 +132,9 @@ class ir_attachment(osv.osv): result[attach.id] = self._file_read(cr, uid, location, attach.store_fname, bin_size) else: result[attach.id] = attach.db_datas + if bin_size: + result[attach.id] = int(result[attach.id]) + return result def _data_set(self, cr, uid, id, name, value, arg, context=None): From 16a545b1bafc89bc68d270bc77c5c5edddfb7367 Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Fri, 24 Apr 2015 11:14:22 +0200 Subject: [PATCH 2/2] [ADD] project: add name to the filter to create context with search_default_Member --- addons/project/project_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 89a3d1fca2f..1f558a5e098 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -178,7 +178,7 @@ - +