Merge lp:~openerp-dev/openerp-web/7.0-opw-584983-rha into lp:openerp-web/7.0

Proposed by Rifakat Husen (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/7.0-opw-584983-rha
Merge into: lp:openerp-web/7.0
Diff against target: 25 lines (+6/-4)
1 file modified
addons/web/controllers/main.py (+6/-4)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-opw-584983-rha
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+145573@code.launchpad.net

Description of the change

Hello,

Problem: When try downloading any file from wizard that put file name as the model's name.

Currently when binary field has default value then read() or default_get() are never getting called,
and hence we will not have filename according to filename attrs given in xml.

When save_as_ajax requested from view_form.js at that time value of filename field will not be available, we have to read it.

Code change, when data available then only reads filename attribute otherwise read data as well as filename.

Thanks for your review and feedback.

Regards,
Rifakat Haradwala

To post a comment you must log in.

Unmerged revisions

3732. By Rifakat Husen (OpenERP)

[FIX] main.py: for wizard, name of the file to download from binary field should not be wizard model name,
if binary field has filename='name' and default value is already set for name then file to download with this name,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/controllers/main.py'
--- addons/web/controllers/main.py 2013-01-29 14:26:38 +0000
+++ addons/web/controllers/main.py 2013-01-30 10:40:27 +0000
@@ -1250,15 +1250,17 @@
1250 context = jdata.get('context', {})1250 context = jdata.get('context', {})
12511251
1252 Model = req.session.model(model)1252 Model = req.session.model(model)
1253 fields = [field]1253 fields = []
1254 if not data:
1255 fields.append(field)
1254 if filename_field:1256 if filename_field:
1255 fields.append(filename_field)1257 fields.append(filename_field)
1256 if data:1258 if data:
1257 res = { field: data }1259 res = { field: data }
1258 elif id:1260 if id:
1259 res = Model.read([int(id)], fields, context)[0]1261 res.update(Model.read([int(id)], fields, context)[0])
1260 else:1262 else:
1261 res = Model.default_get(fields, context)1263 res.update(Model.default_get(fields, context))
1262 filecontent = base64.b64decode(res.get(field, ''))1264 filecontent = base64.b64decode(res.get(field, ''))
1263 if not filecontent:1265 if not filecontent:
1264 raise ValueError(_("No content found for field '%s' on '%s:%s'") %1266 raise ValueError(_("No content found for field '%s' on '%s:%s'") %