Bhumi Thakkar (Open ERP) has proposed merging
lp:~openerp-dev/openerp-web/6.1-opw-576425-bth into lp:openerp-web/6.1.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-576425-bth/+merge/114614
Hello,
error when click on Save As button in attachments form when sending email.
1. Setting => Configuration => Email. Open or create any record.
2. Open Attachment tab. Click on Add Button => Create new attachment.
3. Select any file and then click on Save As button.
Observed: Error is coming "ValueError: No content found for field 'datas' on
'ir.attachment:'".
Expected: Download selected file
file content and file name both arguments are passed from js with 'saveas_ajax'
method and parsing json data in saveas_ajax method. If attachment is exist in
model then download from that if not then download selected file. After click
on clear button download selected file if not selected then open attachment is
downloaded.
Thanks.
--
https://code.launchpad.net/~openerp-dev/openerp-web/6.1-opw-576425-bth/+merge/114614
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openerp-web/6.1-opw-576425-bth.
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2012-06-29 09:57:53 +0000
+++ addons/web/controllers/main.py 2012-07-12 11:34:33 +0000
@@ -1445,27 +1445,36 @@
jdata = simplejson.loads(data)
model = jdata['model']
field = jdata['field']
+ content = jdata.get('filecontent', None)
+ fname = jdata.get('filename', None)
id = jdata.get('id', None)
filename_field = jdata.get('filename_field', None)
context = jdata.get('context', dict())
-
context = req.session.eval_context(context)
Model = req.session.model(model)
fields = [field]
+
if filename_field:
fields.append(filename_field)
if id:
res = Model.read([int(id)], fields, context)[0]
else:
res = Model.default_get(fields, context)
- filecontent = base64.b64decode(res.get(field, ''))
+ if content:
+ filecontent = base64.b64decode(content)
+ else:
+ filecontent = base64.b64decode(res.get(field, ''))
+ if fname:
+ filename = fname
+ else:
+ filename = '%s_%s' % (model.replace('.', '_'), id)
+ if filename_field:
+ filename = res.get(filename_field, '') or filename
+
if not filecontent:
raise ValueError("No content found for field '%s' on '%s:%s'" %
(field, model, id))
else:
- filename = '%s_%s' % (model.replace('.', '_'), id)
- if filename_field:
- filename = res.get(filename_field, '') or filename
return req.make_response(filecontent,
headers=[('Content-Type', 'application/octet-stream'),
('Content-Disposition', self.content_disposition(filename, req))],
=== modified file 'addons/web/static/src/js/view_form.js'
--- addons/web/static/src/js/view_form.js 2012-06-29 15:28:11 +0000
+++ addons/web/static/src/js/view_form.js 2012-07-12 11:34:33 +0000
@@ -3438,6 +3438,8 @@
id: (this.view.datarecord.id || ''),
field: this.name,
filename_field: (this.node.attrs.filename || ''),
+ filecontent: this.filecontent || '',
+ filename: this.filename || '',
context: this.view.dataset.get_context()
})},
complete: $.unblockUI,
@@ -3480,6 +3482,8 @@
},
on_file_uploaded_and_valid: function(size, name, content_type, file_base64) {
this.value = file_base64;
+ this.filecontent = file_base64;
+ this.filename = name;
this.binary_value = true;
var show_value = name + " (" + this.human_filesize(size) + ")";
this.$element.find('input').eq(0).val(show_value);
_______________________________________________
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