From 1942522969753e29ace00125e9f6186f66905588 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 23 Jun 2015 11:46:20 +0200 Subject: [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 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'addons/web/static/src/js') 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_ + }); + } } }); -- cgit v1.2.3