Merge lp:~therp-nl/openerp-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading into lp:openerp-web/7.0

Proposed by Stefan Rijnhart (Opener)
Status: Needs review
Proposed branch: lp:~therp-nl/openerp-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading
Merge into: lp:openerp-web/7.0
Diff against target: 48 lines (+8/-8)
3 files modified
addons/web/static/src/js/data.js (+1/-1)
addons/web/static/src/js/view_form.js (+4/-0)
addons/web/static/src/js/view_list.js (+3/-7)
To merge this branch: bzr merge lp:~therp-nl/openerp-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+210418@code.launchpad.net

Description of the change

Fix binary fields in one2many widgets:
- Don't retrieve the binary contents just to display the size, but pass context with bin_size=True instead
- Always pass filename in download link

Combination of patches from the bug report from Enrico Ganzaroli, Cedric Le Brouster and the last commit from myself which actually prevents the preloading of the binaries.

To post a comment you must log in.

Unmerged revisions

4160. By Stefan Rijnhart (Opener)

[FIX] o2m dataset's get_context to take additional context as does _super()

4159. By Enrico Ganzaroli

[FIX] Pass options containing context to read_ids()

4158. By Cedric Le Brouster(OpenFire)

[FIX] Filename of downloaded binary from list view

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/data.js'
--- addons/web/static/src/js/data.js 2014-02-18 10:14:38 +0000
+++ addons/web/static/src/js/data.js 2014-03-11 14:24:10 +0000
@@ -664,7 +664,7 @@
664 var offset = options.offset || 0,664 var offset = options.offset || 0,
665 limit = options.limit || false;665 limit = options.limit || false;
666 var end_pos = limit && limit !== -1 ? offset + limit : this.ids.length;666 var end_pos = limit && limit !== -1 ? offset + limit : this.ids.length;
667 return this.read_ids(this.ids.slice(offset, end_pos), fields);667 return this.read_ids(this.ids.slice(offset, end_pos), fields, options);
668 },668 },
669 set_ids: function (ids) {669 set_ids: function (ids) {
670 this.ids = ids;670 this.ids = ids;
671671
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2014-03-11 09:15:22 +0000
+++ addons/web/static/src/js/view_form.js 2014-03-11 14:24:10 +0000
@@ -3821,6 +3821,10 @@
3821instance.web.form.One2ManyDataSet = instance.web.BufferedDataSet.extend({3821instance.web.form.One2ManyDataSet = instance.web.BufferedDataSet.extend({
3822 get_context: function() {3822 get_context: function() {
3823 this.context = this.o2m.build_context();3823 this.context = this.o2m.build_context();
3824 var self = this;
3825 _.each(arguments, function(context) {
3826 self.context.add(context);
3827 });
3824 return this.context;3828 return this.context;
3825 }3829 }
3826});3830});
38273831
=== modified file 'addons/web/static/src/js/view_list.js'
--- addons/web/static/src/js/view_list.js 2014-03-03 16:41:14 +0000
+++ addons/web/static/src/js/view_list.js 2014-03-11 14:24:10 +0000
@@ -2257,13 +2257,9 @@
2257 var text = _t("Download");2257 var text = _t("Download");
2258 var value = row_data[this.id].value;2258 var value = row_data[this.id].value;
2259 var download_url;2259 var download_url;
2260 if (value && value.substr(0, 10).indexOf(' ') == -1) {2260 download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
2261 download_url = "data:application/octet-stream;base64," + value;2261 if (this.filename) {
2262 } else {2262 download_url += '&filename_field=' + this.filename;
2263 download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
2264 if (this.filename) {
2265 download_url += '&filename_field=' + this.filename;
2266 }
2267 }2263 }
2268 if (this.filename && row_data[this.filename]) {2264 if (this.filename && row_data[this.filename]) {
2269 text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(2265 text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(