[FIX] downloading files from an unsaved/in-memory wizard
fallback on default_get if record does not exist in db, as for e.g. Thunderbird and Outlook plugins lp bug: https://launchpad.net/bugs/856487 fixed bzr revid: xmo@openerp.com-20111017145849-p8dq0eprkru4xtl1
This commit is contained in:
parent
5823bf1634
commit
548a809ff5
|
@ -1003,7 +1003,10 @@ class Binary(openerpweb.Controller):
|
|||
def saveas(self, req, model, id, field, fieldname, **kw):
|
||||
Model = req.session.model(model)
|
||||
context = req.session.eval_context(req.context)
|
||||
res = Model.read([int(id)], [field, fieldname], context)[0]
|
||||
if id:
|
||||
res = Model.read([int(id)], [field, fieldname], context)[0]
|
||||
else:
|
||||
res = Model.default_get([field, fieldname], context)
|
||||
filecontent = base64.b64decode(res.get(field, ''))
|
||||
if not filecontent:
|
||||
return req.not_found()
|
||||
|
|
|
@ -2642,14 +2642,10 @@ openerp.web.form.FieldBinary = openerp.web.form.Field.extend({
|
|||
on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
|
||||
},
|
||||
on_save_as: function() {
|
||||
if (!this.view.datarecord.id) {
|
||||
this.do_warn("Can't save file", "The record has not yet been saved");
|
||||
} else {
|
||||
var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' +
|
||||
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name +
|
||||
'&fieldname=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime());
|
||||
window.open(url);
|
||||
}
|
||||
var url = '/web/binary/saveas?session_id=' + this.session.session_id + '&model=' +
|
||||
this.view.dataset.model +'&id=' + (this.view.datarecord.id || '') + '&field=' + this.name +
|
||||
'&fieldname=' + (this.node.attrs.filename || '') + '&t=' + (new Date().getTime());
|
||||
window.open(url);
|
||||
},
|
||||
on_clear: function() {
|
||||
if (this.value !== false) {
|
||||
|
|
Loading…
Reference in New Issue