Merge lp:~openerp-dev/openobject-addons/6.1-opw-578969-cbi into lp:openobject-addons/6.1

Proposed by Chris Biersbach (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/6.1-opw-578969-cbi
Merge into: lp:openobject-addons/6.1
Diff against target: 63 lines (+11/-7)
1 file modified
survey/wizard/survey_send_invitation.py (+11/-7)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/6.1-opw-578969-cbi
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+127645@code.launchpad.net

Description of the change

To reproduce this issue, try to send invitations via the module survey.

On non-english-locale systems, this will cause a Traceback with a UnicodeDecodeError.

The cause of this is the function string.letters, called when generating the password.
This return only a-z,A-Z in english locale but also special characters in other locale.
The solution was to replace it with a call to string.ascii_letters, which always return a-z,A-Z.

I also removed some unused code that has been there for a long time (2010) and was never used since, so it is not needed anymore. I figured that it was some old debugging code that was not removed.

To post a comment you must log in.
7013. By Chris Biersbach (OpenERP)

[FIX] A report was created in a directory where sometimes the user has no write access. I changed this to automatically detect the temporary folder of the OS and create the report there, which is always possible

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello,

This bug was qualified as Confirmed on Trunk (means still existing and reproducible). A Merge Proposal for trunk was created to fix it. Here is the link to follow the MP on Launchpad https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-opw-578969-port-cha/+merge/138964 and be informed once it's been merged in trunk: ... If this Merge Proposal could not be merged in v6.1 at the release of v7.0, it will be closed.

Thanks,
Naresh Soni

Unmerged revisions

7013. By Chris Biersbach (OpenERP)

[FIX] A report was created in a directory where sometimes the user has no write access. I changed this to automatically detect the temporary folder of the OS and create the report there, which is always possible

7012. By Chris Biersbach (OpenERP)

[FIX] changed a call to string.letters into a call to string.ascii_letters to avoid problems related to non-ascii characters. Also removed some unused code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'survey/wizard/survey_send_invitation.py'
2--- survey/wizard/survey_send_invitation.py 2011-10-20 12:37:42 +0000
3+++ survey/wizard/survey_send_invitation.py 2012-10-09 12:05:26 +0000
4@@ -56,7 +56,7 @@
5 }
6
7 def genpasswd(self):
8- chars = string.letters + string.digits
9+ chars = string.ascii_letters + string.digits
10 return ''.join([choice(chars) for i in range(6)])
11
12 def default_get(self, cr, uid, fields_list, context=None):
13@@ -81,7 +81,13 @@
14 if not report_name or not res_ids:
15 return (False, Exception('Report name and Resources ids are required !!!'))
16 try:
17- ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
18+ # Windows: Use %temp% environment variable
19+ if os.name == 'nt':
20+ tempfolder = os.environ['temp']
21+ # Unixoid Oses: user /tmp
22+ elif os.name == 'posix':
23+ tempfolder = '/tmp'
24+ ret_file_name = tempfolder + os.sep + file_name + '.pdf'
25 service = netsvc.LocalService(report_name);
26 (result, format) = service.create(cr, uid, res_ids, {}, {})
27 fp = open(ret_file_name, 'wb+');
28@@ -111,7 +117,6 @@
29 act_id = self.pool.get('ir.actions.act_window')
30 act_id = act_id.search(cr, uid, [('res_model', '=' , 'survey.name.wiz'), \
31 ('view_type', '=', 'form')])
32- out = "login,password\n"
33 skipped = 0
34 existing = ""
35 created = ""
36@@ -125,8 +130,8 @@
37 for use in exist_user:
38 new_user.append(use.id)
39 for id in survey_ref.browse(cr, uid, survey_ids):
40- report = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
41- file = open(addons.get_module_resource('survey', 'report') + id.title +".pdf")
42+ report, ret_file_name = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
43+ file = open(ret_file_name)
44 file_data = ""
45 while 1:
46 line = file.readline()
47@@ -135,7 +140,7 @@
48 break
49 file.close()
50 attachments[id.title +".pdf"] = file_data
51- os.remove(addons.get_module_resource('survey', 'report') + id.title +".pdf")
52+ os.remove(ret_file_name)
53
54 for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):
55 for addr in partner.address:
56@@ -158,7 +163,6 @@
57 continue
58
59 passwd= self.genpasswd()
60- out+= addr.email + ',' + passwd + '\n'
61 mail= record['mail'] % {'login' : addr.email, 'passwd' : passwd, 'name' : addr.name}
62 if record['send_mail']:
63 ans = mail_message.schedule_with_attach(cr, uid, record['mail_from'], [addr.email], \