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
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 14:24:10 +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-11 09:15:22 +0000
16+++ addons/web/static/src/js/view_form.js 2014-03-11 14:24:10 +0000
17@@ -3821,6 +3821,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 14:24:10 +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(