Mohammed Shekha(Open ERP) has proposed merging 
lp:~openerp-dev/openerp-web/6.1-opw-573324-msh into lp:openerp-web/6.1.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #950116 in OpenERP Web: "[Web client] Set name when uploading an image is 
broken on 6.1"
  https://bugs.launchpad.net/openerp-web/+bug/950116

For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-573324-msh/+merge/100942

Hello,

Fixed the issue of filename in wdget="image", when there is a widget="image" 
and if you set filename="any field", so the filename is not set in that field.

Scenario :
Install sale module
Then :
>From the menu Administration > Customisation > User Interface > Views
Open the view product.normal.form
Edit it and replace the line
<field name="product_image" widget='image' nolabel="1"/>
by
<field name="product_image" widget='image' nolabel="1" filename="default_code"/>

Then open the form product
Choose an image

Expected :
The field "reference" should contain the file name
The field "image" should contain the image

On Web client the field "reference" is empty.

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-573324-msh/+merge/100942
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openerp-web/6.1-opw-573324-msh.
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js	2012-03-05 19:58:00 +0000
+++ addons/web/static/src/js/view_form.js	2012-04-05 11:38:23 +0000
@@ -3222,6 +3222,13 @@
             error: openerp.webclient.crashmanager.on_rpc_error
         });
     },
+    set_filename: function(value) {
+        var filename = this.node.attrs.filename;
+        if (this.view.fields[filename]) {
+            this.view.fields[filename].set_value(value);
+            this.view.fields[filename].on_ui_change();
+        }
+    },
     on_clear: function() {
         if (this.value !== false) {
             this.value = false;
@@ -3256,13 +3263,6 @@
         this.$element.find('input').eq(0).val(show_value);
         this.set_filename(name);
     },
-    set_filename: function(value) {
-        var filename = this.node.attrs.filename;
-        if (this.view.fields[filename]) {
-            this.view.fields[filename].set_value(value);
-            this.view.fields[filename].on_ui_change();
-        }
-    },
     on_clear: function() {
         this._super.apply(this, arguments);
         this.$element.find('input').eq(0).val('');
@@ -3298,10 +3298,12 @@
         this.value = file_base64;
         this.binary_value = true;
         this.$image.attr('src', 'data:' + (content_type || 'image/png') + ';base64,' + file_base64);
+        this.set_filename(name);
     },
     on_clear: function() {
         this._super.apply(this, arguments);
         this.$image.attr('src', '/web/static/src/img/placeholder.png');
+        this.set_filename('');
     }
 });
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to