Merge lp:~openerp-dev/openerp-web/6.1-opw-581888-msh into lp:openerp-web/6.1

Proposed by Mohammed Shekha(Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/6.1-opw-581888-msh
Merge into: lp:openerp-web/6.1
Diff against target: 20 lines (+7/-3)
1 file modified
addons/web/static/src/js/view_form.js (+7/-3)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/6.1-opw-581888-msh
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+134616@code.launchpad.net

Description of the change

Hello,

Fixed the issue of image not displayed newly created record when it is return from on_change result or from default values because still datarecord will not have id so it can not read image from database, hence set the value in src directly with content-type image/png.

Demo :- To generate this create an on_change method which returns binary image as a result, now call that on_change method will not display image in image widget, I have created an on_change method on hr.employee form for demo, added a binary field in res.users for instance.

Expected :- when on_change returns binary data it should be displayed on image widget.

Thanks.

To post a comment you must log in.

Unmerged revisions

2482. By Mohammed Shekha(Open ERP)

[FIX]Fixed the issue of image not displayed newly created record when it is return from on_change result or from default values because still datarecord will not have id so it can not read image from database, hence set the value in src directly with content-type image/png

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-10-23 07:30:10 +0000
+++ addons/web/static/src/js/view_form.js 2012-11-16 07:41:22 +0000
@@ -3562,9 +3562,13 @@
3562 set_value: function(value) {3562 set_value: function(value) {
3563 this._super.apply(this, arguments);3563 this._super.apply(this, arguments);
3564 this.set_image_maxwidth();3564 this.set_image_maxwidth();
3565 var url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' +3565 if(this.view.datarecord.id) {
3566 this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime());3566 var url = '/web/binary/image?session_id=' + this.session.session_id + '&model=' +
3567 this.$image.attr('src', url);3567 this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime());
3568 this.$image.attr('src', url);
3569 }else {
3570 this.$image.attr('src', 'data:image/png;base64,' + value);
3571 }
3568 },3572 },
3569 set_image_maxwidth: function() {3573 set_image_maxwidth: function() {
3570 this.$image.css('max-width', this.$element.width());3574 this.$image.css('max-width', this.$element.width());