[ADD] Start binary image edition widgets
bzr revid: fme@openerp.com-20110518153356-7c69bg8mdkd9x94p
This commit is contained in:
parent
53c973b38a
commit
0e38585483
|
@ -556,7 +556,7 @@ class FormView(View):
|
|||
return {'fields_view': fields_view}
|
||||
|
||||
@openerpweb.httprequest
|
||||
def image(self, request, session_id, model, id, field):
|
||||
def image(self, request, session_id, model, id, field, **kw):
|
||||
cherrypy.response.headers['Content-Type'] = 'image/png'
|
||||
Model = request.session.model(model)
|
||||
try:
|
||||
|
|
|
@ -1192,11 +1192,24 @@ openerp.base.form.FieldImage = openerp.base.form.Field.extend({
|
|||
this._super(view, node);
|
||||
this.template = "FieldImage";
|
||||
},
|
||||
start: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.$element.find('button.oe-binary-image-clear').click(this.on_clear);
|
||||
},
|
||||
set_value_from_ui: function() {
|
||||
},
|
||||
on_clear: function() {
|
||||
if (this.value !== false) {
|
||||
this.value = false;
|
||||
this.$element.find('img.oe-binary-image').attr('src', '/base/static/src/img/placeholder.png');
|
||||
this.on_ui_change();
|
||||
}
|
||||
},
|
||||
set_value: function(value) {
|
||||
this._super.apply(this, arguments);
|
||||
var url = '/base/formview/image?session_id=' + this.session.session_id + '&model=' +
|
||||
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name
|
||||
this.$element.find('img').show().attr('src', url);
|
||||
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name + '&t=' + (new Date().getTime())
|
||||
this.$element.find('img.oe-binary-image').attr('src', url);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@
|
|||
<t t-call="FieldChar"/>
|
||||
</td>
|
||||
<td width="16">
|
||||
<button class="button" title="Send an e-mail with your default e-mail client">
|
||||
<button type="button" class="button" title="Send an e-mail with your default e-mail client">
|
||||
<img src="/base/static/src/img/icons/terp-mail-message-new.png"/>
|
||||
</button>
|
||||
</td>
|
||||
|
@ -387,13 +387,32 @@
|
|||
</div>
|
||||
</t>
|
||||
<t t-name="FieldImage">
|
||||
<img align="left" border="1" style="display: none"
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="/base/static/src/img/placeholder.png" class="oe-binary-image" border="1"
|
||||
t-att-id="widget.element_id + '_field'"
|
||||
t-att-name="widget.name"
|
||||
t-att-class="'field_' + widget.type"
|
||||
t-att-width="widget.node.attrs.img_width || widget.node.attrs.width"
|
||||
t-att-height="widget.node.attrs.img_height || widget.node.attrs.height"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" valign="bottom" height="25">
|
||||
<button class="button oe-binary-image-set" type="button" title="Set Image">
|
||||
<img src="/base/static/src/img/icons/STOCK_DIRECTORY.png"/>
|
||||
</button>
|
||||
<!--<button class="button oe-binary-image-save" type="button" title="Save As">
|
||||
<img src="/base/static/src/img/icons/gtk-save.png"/>
|
||||
</button>-->
|
||||
<button class="button oe-binary-image-clear" type="button" title="Clear">
|
||||
<img src="/base/static/src/img/icons/STOCK_MISSING_IMAGE.png"/>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</t>
|
||||
<t t-name="WidgetButton">
|
||||
<button type="button"
|
||||
|
|
Loading…
Reference in New Issue