Merge lp:~therp-nl/ocb-web/6.1-lp1197783-file_upload_firefox_22 into lp:ocb-web/6.1

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 2514
Proposed branch: lp:~therp-nl/ocb-web/6.1-lp1197783-file_upload_firefox_22
Merge into: lp:ocb-web/6.1
Diff against target: 68 lines (+9/-6)
3 files modified
addons/web/controllers/main.py (+1/-1)
addons/web/static/src/js/view_form.js (+2/-2)
addons/web/static/src/xml/base.xml (+6/-3)
To merge this branch: bzr merge lp:~therp-nl/ocb-web/6.1-lp1197783-file_upload_firefox_22
Reviewer Review Type Date Requested Status
Holger Brunn (Therp) code review Approve
Review via email: mp+173042@code.launchpad.net

Description of the change

Same as https://code.launchpad.net/~therp-nl/openerp-web/6.1-lp1197783-file_upload_firefox_22/+merge/173033

OpenERP 6.1 stores the callback function on the iframe that loads the code that calls the callback function. In Firefox 22, when the callback is called, it is no longer present on the iframe.

My suggestion in this branch is to use a seemingly unused input field that is already named 'callback'. In order to retrieve it from the iframe, I am assigning it an id.

Tested in Firefox 21, 22 and Chromium 28.0.1500.52

To post a comment you must log in.
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/controllers/main.py'
2--- addons/web/controllers/main.py 2012-11-04 19:25:08 +0000
3+++ addons/web/controllers/main.py 2013-07-04 15:20:40 +0000
4@@ -1481,7 +1481,7 @@
5 try:
6 out = """<script language="javascript" type="text/javascript">
7 var win = window.top.window,
8- callback = win[%s];
9+ callback = win[%s + '_callback'];
10 if (typeof(callback) === 'function') {
11 callback.apply(this, %s);
12 } else {
13
14=== modified file 'addons/web/static/src/js/view_form.js'
15--- addons/web/static/src/js/view_form.js 2013-04-10 11:56:57 +0000
16+++ addons/web/static/src/js/view_form.js 2013-07-04 15:20:40 +0000
17@@ -832,7 +832,7 @@
18 this.$element.find('.oe-sidebar-attachment-delete').click(this.on_attachment_delete);
19 },
20 on_attachment_changed: function(e) {
21- window[this.element_id + '_iframe'] = this.do_update;
22+ window[this.element_id + '_iframe_callback'] = this.do_update;
23 var $e = $(e.target);
24 if ($e.val() != '') {
25 this.$element.find('form.oe-binary-form').submit();
26@@ -3490,7 +3490,7 @@
27 // TODO: on modern browsers, we could directly read the file locally on client ready to be used on image cropper
28 // http://www.html5rocks.com/tutorials/file/dndfiles/
29 // http://deepliquid.com/projects/Jcrop/demos.php?demo=handler
30- window[this.iframe] = this.on_file_uploaded;
31+ window[this.iframe + '_callback'] = this.on_file_uploaded;
32 if ($(e.target).val() != '') {
33 this.$element.find('form.oe-binary-form input[name=session_id]').val(this.session.session_id);
34 this.$element.find('form.oe-binary-form').submit();
35
36=== modified file 'addons/web/static/src/xml/base.xml'
37--- addons/web/static/src/xml/base.xml 2012-08-31 13:12:29 +0000
38+++ addons/web/static/src/xml/base.xml 2013-07-04 15:20:40 +0000
39@@ -769,7 +769,8 @@
40 <form class="oe-binary-form" t-attf-target="#{element_id}_iframe"
41 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload_attachment"'>
42 <input type="hidden" name="session_id" t-att-value="session.session_id"/>
43- <input type="hidden" name="callback" t-attf-value="#{element_id}_iframe"/>
44+ <input type="hidden" name="callback" t-attf-value="#{element_id}_iframe_callback"
45+ t-attf-id="#{element_id}_iframe_callback"/>
46 <input type="hidden" name="model" t-att-value="view.dataset.model"/>
47 <input type="hidden" name="id" t-att-value="view.datarecord.id"/>
48 <button class="oe_button" type="button">
49@@ -1158,7 +1159,8 @@
50 <form class="oe-binary-form" t-att-target="widget.iframe"
51 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>
52 <input type="hidden" name="session_id" value=""/>
53- <input type="hidden" name="callback" t-att-value="widget.iframe"/>
54+ <input type="hidden" name="callback" t-att-value="widget.iframe"
55+ t-att-id='widget.iframe + "_callback"'/>
56 <button class="oe_button" type="button" title="Set Image">
57 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>
58 </button>
59@@ -1201,7 +1203,8 @@
60 <form class="oe-binary-form" t-att-target="widget.iframe"
61 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>
62 <input type="hidden" name="session_id" value=""/>
63- <input type="hidden" name="callback" t-att-value="widget.iframe"/>
64+ <input type="hidden" name="callback" t-att-value="widget.iframe"
65+ t-att-id='widget.iframe + "_callback"'/>
66 <button class="oe_button oe_field_button" type="button" title="Set Image">
67 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>
68 <span>Select</span>

Subscribers

People subscribed via source and target branches