← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~stefan-therp/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading into lp:ocb-web

 

Stefan Rijnhart (Therp) has proposed merging lp:~stefan-therp/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading into lp:ocb-web.

Requested reviews:
  OpenERP Community Backports Team (ocb)
Related bugs:
  Bug #1167429 in OpenERP Web: "[7.0] Wrong binary fields representation in o2m list views and unnecessary preloading"
  https://bugs.launchpad.net/openerp-web/+bug/1167429

For more details, see:
https://code.launchpad.net/~stefan-therp/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading/+merge/210432

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.
-- 
https://code.launchpad.net/~stefan-therp/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading/+merge/210432
Your team OpenERP Community Backports Team is requested to review the proposed merge of lp:~stefan-therp/ocb-web/7.0-lp1167429-binary_fields_in_o2m_representation_and_unnecessary_preloading into lp:ocb-web.
=== 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 15:10:35 +0000
@@ -664,7 +664,7 @@
         var offset = options.offset || 0,
             limit = options.limit || false;
         var end_pos = limit && limit !== -1 ? offset + limit : this.ids.length;
-        return this.read_ids(this.ids.slice(offset, end_pos), fields);
+        return this.read_ids(this.ids.slice(offset, end_pos), fields, options);
     },
     set_ids: function (ids) {
         this.ids = ids;

=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2014-03-07 14:12:57 +0000
+++ addons/web/static/src/js/view_form.js	2014-03-11 15:10:35 +0000
@@ -3823,6 +3823,10 @@
 instance.web.form.One2ManyDataSet = instance.web.BufferedDataSet.extend({
     get_context: function() {
         this.context = this.o2m.build_context();
+        var self = this;
+        _.each(arguments, function(context) {
+            self.context.add(context);
+        });
         return this.context;
     }
 });

=== 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 15:10:35 +0000
@@ -2257,13 +2257,9 @@
         var text = _t("Download");
         var value = row_data[this.id].value;
         var download_url;
-        if (value && value.substr(0, 10).indexOf(' ') == -1) {
-            download_url = "data:application/octet-stream;base64," + value;
-        } else {
-            download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
-            if (this.filename) {
-                download_url += '&filename_field=' + this.filename;
-            }
+        download_url = instance.session.url('/web/binary/saveas', {model: options.model, field: this.id, id: options.id});
+        if (this.filename) {
+            download_url += '&filename_field=' + this.filename;
         }
         if (this.filename && row_data[this.filename]) {
             text = _.str.sprintf(_t("Download \"%s\""), instance.web.format_value(


Follow ups