Merge lp:~stefan-opener/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading into lp:ocb-web

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 4170
Proposed branch: lp:~stefan-opener/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading
Merge into: lp:ocb-web
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:~stefan-opener/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Pedro Manuel Baeza Approve
Holger Brunn (Therp) code review Approve
Review via email: mp+210432@code.launchpad.net

Description of the change

Automatically derived from https://code.launchpad.net/~therp-nl/openerp-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading for https://code.launchpad.net/~openerp/openerp-web/7.0. Below is a copy of the original description.

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.
Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

I was puzzled by 36f at first, but that's indeed not necessary if there's no preloading

review: Approve (code review)
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Very good improvement. Thanks!

Regards.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) :
review: Approve
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/js/data.js'
2--- addons/web/static/src/js/data.js 2014-02-18 10:14:38 +0000
3+++ addons/web/static/src/js/data.js 2014-03-11 15:10:35 +0000
4@@ -664,7 +664,7 @@
5 var offset = options.offset || 0,
6 limit = options.limit || false;
7 var end_pos = limit && limit !== -1 ? offset + limit : this.ids.length;
8- return this.read_ids(this.ids.slice(offset, end_pos), fields);
9+ return this.read_ids(this.ids.slice(offset, end_pos), fields, options);
10 },
11 set_ids: function (ids) {
12 this.ids = ids;
13
14=== modified file 'addons/web/static/src/js/view_form.js'
15--- addons/web/static/src/js/view_form.js 2014-03-07 14:12:57 +0000
16+++ addons/web/static/src/js/view_form.js 2014-03-11 15:10:35 +0000
17@@ -3823,6 +3823,10 @@
18 instance.web.form.One2ManyDataSet = instance.web.BufferedDataSet.extend({
19 get_context: function() {
20 this.context = this.o2m.build_context();
21+ var self = this;
22+ _.each(arguments, function(context) {
23+ self.context.add(context);
24+ });
25 return this.context;
26 }
27 });
28
29=== modified file 'addons/web/static/src/js/view_list.js'
30--- addons/web/static/src/js/view_list.js 2014-03-03 16:41:14 +0000
31+++ addons/web/static/src/js/view_list.js 2014-03-11 15:10:35 +0000
32@@ -2257,13 +2257,9 @@
33 var text = _t("Download");
34 var value = row_data[this.id].value;
35 var download_url;
36- if (value && value.substr(0, 10).indexOf(' ') == -1) {
37- download_url = "data:application/octet-stream;base64," + value;
38- } else {
39- download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
40- if (this.filename) {
41- download_url += '&filename_field=' + this.filename;
42- }
43+ download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
44+ if (this.filename) {
45+ download_url += '&filename_field=' + this.filename;
46 }
47 if (this.filename && row_data[this.filename]) {
48 text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(