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

Proposed by Stefan Rijnhart (Opener)
Status: Merged
Merged at revision: 2518
Proposed branch: lp:~therp-nl/openerp-web/6.1-lp1197783-file_upload_firefox_22
Merge into: lp:openerp-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/openerp-web/6.1-lp1197783-file_upload_firefox_22
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) tested on customers Approve
Holger Brunn (Therp) (community) code review Approve
OpenERP Core Team Pending
Review via email: mp+173033@code.launchpad.net

Description of the change

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)
Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve (tested on customers)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2012-11-04 19:25:08 +0000
+++ addons/web/controllers/main.py 2013-07-04 14:38:23 +0000
@@ -1481,7 +1481,7 @@
1481 try:1481 try:
1482 out = """<script language="javascript" type="text/javascript">1482 out = """<script language="javascript" type="text/javascript">
1483 var win = window.top.window,1483 var win = window.top.window,
1484 callback = win[%s];1484 callback = win[%s + '_callback'];
1485 if (typeof(callback) === 'function') {1485 if (typeof(callback) === 'function') {
1486 callback.apply(this, %s);1486 callback.apply(this, %s);
1487 } else {1487 } else {
14881488
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2013-03-13 09:26:29 +0000
+++ addons/web/static/src/js/view_form.js 2013-07-04 14:38:23 +0000
@@ -832,7 +832,7 @@
832 this.$element.find('.oe-sidebar-attachment-delete').click(this.on_attachment_delete);832 this.$element.find('.oe-sidebar-attachment-delete').click(this.on_attachment_delete);
833 },833 },
834 on_attachment_changed: function(e) {834 on_attachment_changed: function(e) {
835 window[this.element_id + '_iframe'] = this.do_update;835 window[this.element_id + '_iframe_callback'] = this.do_update;
836 var $e = $(e.target);836 var $e = $(e.target);
837 if ($e.val() != '') {837 if ($e.val() != '') {
838 this.$element.find('form.oe-binary-form').submit();838 this.$element.find('form.oe-binary-form').submit();
@@ -3484,7 +3484,7 @@
3484 // TODO: on modern browsers, we could directly read the file locally on client ready to be used on image cropper3484 // TODO: on modern browsers, we could directly read the file locally on client ready to be used on image cropper
3485 // http://www.html5rocks.com/tutorials/file/dndfiles/3485 // http://www.html5rocks.com/tutorials/file/dndfiles/
3486 // http://deepliquid.com/projects/Jcrop/demos.php?demo=handler3486 // http://deepliquid.com/projects/Jcrop/demos.php?demo=handler
3487 window[this.iframe] = this.on_file_uploaded;3487 window[this.iframe + '_callback'] = this.on_file_uploaded;
3488 if ($(e.target).val() != '') {3488 if ($(e.target).val() != '') {
3489 this.$element.find('form.oe-binary-form input[name=session_id]').val(this.session.session_id);3489 this.$element.find('form.oe-binary-form input[name=session_id]').val(this.session.session_id);
3490 this.$element.find('form.oe-binary-form').submit();3490 this.$element.find('form.oe-binary-form').submit();
34913491
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2012-08-31 13:12:29 +0000
+++ addons/web/static/src/xml/base.xml 2013-07-04 14:38:23 +0000
@@ -769,7 +769,8 @@
769 <form class="oe-binary-form" t-attf-target="#{element_id}_iframe"769 <form class="oe-binary-form" t-attf-target="#{element_id}_iframe"
770 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload_attachment"'>770 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload_attachment"'>
771 <input type="hidden" name="session_id" t-att-value="session.session_id"/>771 <input type="hidden" name="session_id" t-att-value="session.session_id"/>
772 <input type="hidden" name="callback" t-attf-value="#{element_id}_iframe"/>772 <input type="hidden" name="callback" t-attf-value="#{element_id}_iframe_callback"
773 t-attf-id="#{element_id}_iframe_callback"/>
773 <input type="hidden" name="model" t-att-value="view.dataset.model"/>774 <input type="hidden" name="model" t-att-value="view.dataset.model"/>
774 <input type="hidden" name="id" t-att-value="view.datarecord.id"/>775 <input type="hidden" name="id" t-att-value="view.datarecord.id"/>
775 <button class="oe_button" type="button">776 <button class="oe_button" type="button">
@@ -1158,7 +1159,8 @@
1158 <form class="oe-binary-form" t-att-target="widget.iframe"1159 <form class="oe-binary-form" t-att-target="widget.iframe"
1159 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>1160 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>
1160 <input type="hidden" name="session_id" value=""/>1161 <input type="hidden" name="session_id" value=""/>
1161 <input type="hidden" name="callback" t-att-value="widget.iframe"/>1162 <input type="hidden" name="callback" t-att-value="widget.iframe"
1163 t-att-id='widget.iframe + "_callback"'/>
1162 <button class="oe_button" type="button" title="Set Image">1164 <button class="oe_button" type="button" title="Set Image">
1163 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>1165 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>
1164 </button>1166 </button>
@@ -1201,7 +1203,8 @@
1201 <form class="oe-binary-form" t-att-target="widget.iframe"1203 <form class="oe-binary-form" t-att-target="widget.iframe"
1202 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>1204 method="post" enctype="multipart/form-data" t-att-action='_s + "/web/binary/upload"'>
1203 <input type="hidden" name="session_id" value=""/>1205 <input type="hidden" name="session_id" value=""/>
1204 <input type="hidden" name="callback" t-att-value="widget.iframe"/>1206 <input type="hidden" name="callback" t-att-value="widget.iframe"
1207 t-att-id='widget.iframe + "_callback"'/>
1205 <button class="oe_button oe_field_button" type="button" title="Set Image">1208 <button class="oe_button oe_field_button" type="button" title="Set Image">
1206 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>1209 <img t-att-src='_s + "/web/static/src/img/icons/STOCK_DIRECTORY.png"'/>
1207 <span>Select</span>1210 <span>Select</span>