Merge lp:~openerp-dev/openerp-web/7.0-fix-many2many_binary-chm into lp:openerp-web/7.0

Proposed by Christophe Matthieu (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/7.0-fix-many2many_binary-chm
Merge into: lp:openerp-web/7.0
Diff against target: 58 lines (+9/-7)
2 files modified
addons/web/static/src/js/view_form.js (+8/-6)
addons/web/static/src/xml/base.xml (+1/-1)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-fix-many2many_binary-chm
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+197076@code.launchpad.net

Description of the change

[FIX] view_form: many2many_binary error when rendering twice (with an onchange for e.g.)

Try: sales, quotation, click on 'send by email'

To post a comment you must log in.

Unmerged revisions

4081. By Christophe Matthieu (OpenERP)

[FIX] web_form: many2many_binary error when rendering twice (with an onchange for e.g.)

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/view_form.js'
2--- addons/web/static/src/js/view_form.js 2013-11-20 18:53:37 +0000
3+++ addons/web/static/src/js/view_form.js 2013-11-28 14:12:30 +0000
4@@ -5219,16 +5219,17 @@
5 },
6 read_name_values : function () {
7 var self = this;
8- // select the list of id for a get_name
9+ // select the list of id for a get_nam
10+ var ids = this.get('value');
11 var values = [];
12- _.each(this.get('value'), function (val) {
13+ _.each(ids, function (val) {
14 if (typeof val != 'object') {
15 values.push(val);
16 }
17 });
18 // send request for get_name
19 if (values.length) {
20- return this.ds_file.call('read', [values, ['id', 'name', 'datas_fname']]).done(function (datas) {
21+ return this.ds_file.call('read', [values, ['id', 'name', 'datas_fname']]).then(function (datas) {
22 _.each(datas, function (data) {
23 data.no_unlink = true;
24 data.url = self.session.url('/web/binary/saveas', {model: 'ir.attachment', field: 'datas', filename_field: 'datas_fname', id: data.id});
25@@ -5239,16 +5240,17 @@
26 }
27 });
28 });
29+ return ids;
30 });
31 } else {
32- return $.when(this.get('value'));
33+ return $.when(ids);
34 }
35 },
36 render_value: function () {
37 var self = this;
38- this.read_name_values().then(function (datas) {
39+ this.read_name_values().then(function (ids) {
40
41- var render = $(instance.web.qweb.render('FieldBinaryFileUploader.files', {'widget': self}));
42+ var render = $(instance.web.qweb.render('FieldBinaryFileUploader.files', {'widget': self, 'values': ids}));
43 render.on('click', '.oe_delete', _.bind(self.on_file_delete, self));
44 self.$('.oe_placeholder_files, .oe_attachments').replaceWith( render );
45
46
47=== modified file 'addons/web/static/src/xml/base.xml'
48--- addons/web/static/src/xml/base.xml 2013-10-22 16:25:19 +0000
49+++ addons/web/static/src/xml/base.xml 2013-11-28 14:12:30 +0000
50@@ -1293,7 +1293,7 @@
51 <t t-name="FieldBinaryFileUploader.files">
52 <div class="oe_attachments">
53 <t t-if="widget.get('value')">
54- <t t-if="!widget.get('effective_readonly')" t-foreach="widget.get('value')" t-as="file">
55+ <t t-if="!widget.get('effective_readonly')" t-foreach="values" t-as="file">
56 <div class="oe_attachment">
57 <span t-if="(file.upload or file.percent_loaded&lt;100)" t-attf-title="{(file.name || file.filename) + (file.date?' \n('+file.date+')':'' )}" t-attf-name="{file.name || file.filename}">
58 <span class="oe_fileuploader_in_process">...Upload in progress...</span>