Merge lp:~openerp-dev/openobject-addons/trunk-opw-578969-port-cha into lp:openobject-addons

Proposed by Ajay Chauhan(OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-opw-578969-port-cha
Merge into: lp:openobject-addons
Diff against target: 74 lines (+13/-9)
1 file modified
survey/wizard/survey_send_invitation.py (+13/-9)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-opw-578969-port-cha
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+138964@code.launchpad.net

Description of the change

Hello,

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.

code is forward port from 6.1

Thanks,
Ajay Chauhan

To post a comment you must log in.
8270. By Ajay Chauhan(OpenERP)

[MERGE] merge with lp:openobject-addons

Unmerged revisions

8270. By Ajay Chauhan(OpenERP)

[MERGE] merge with lp:openobject-addons

8269. 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

8268. 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.

8267. By Ajay Chauhan(OpenERP)

[FIX] survey: solved valueerror arise when trying to send invitation with diffrent user language ex: 'Dutch'

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 2012-11-29 22:26:45 +0000
3+++ survey/wizard/survey_send_invitation.py 2012-12-13 08:58:21 +0000
4@@ -53,7 +53,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@@ -77,8 +77,8 @@
14 Would you please spent some of your time to fill-in our survey: \n%s\n
15 You can access this survey with the following parameters:
16 URL: %s
17- Your login ID: %%(login)s\n
18- Your password: %%(passwd)s\n
19+ Your login ID: %%(login)s \n
20+ Your password: %%(passwd)s \n
21 \n\n
22 Thanks,''') % (name, self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context))
23 return data
24@@ -87,7 +87,13 @@
25 if not report_name or not res_ids:
26 return (False, Exception('Report name and Resources ids are required !!!'))
27 try:
28- ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'
29+ # Windows: Use %temp% environment variable
30+ if os.name == 'nt':
31+ tempfolder = os.environ['temp']
32+ # Unixoid Oses: user /tmp
33+ elif os.name == 'posix':
34+ tempfolder = '/tmp'
35+ ret_file_name = tempfolder + os.sep + file_name + '.pdf'
36 service = netsvc.LocalService(report_name);
37 (result, format) = service.create(cr, uid, res_ids, {}, {})
38 fp = open(ret_file_name, 'wb+');
39@@ -117,7 +123,6 @@
40 act_id = self.pool.get('ir.actions.act_window')
41 act_id = act_id.search(cr, uid, [('res_model', '=' , 'survey.name.wiz'), \
42 ('view_type', '=', 'form')])
43- out = "login,password\n"
44 skipped = 0
45 existing = ""
46 created = ""
47@@ -130,8 +135,8 @@
48 for use in exist_user:
49 new_user.append(use.id)
50 for id in survey_ref.browse(cr, uid, survey_ids):
51- report = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
52- file = open(addons.get_module_resource('survey', 'report') + id.title +".pdf")
53+ report, ret_file_name = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
54+ file = open(ret_file_name)
55 file_data = ""
56 while 1:
57 line = file.readline()
58@@ -140,7 +145,7 @@
59 break
60 file.close()
61 attachments[id.title +".pdf"] = file_data
62- os.remove(addons.get_module_resource('survey', 'report') + id.title +".pdf")
63+ os.remove(ret_file_name)
64
65 for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):
66 if not partner.email:
67@@ -168,7 +173,6 @@
68 continue
69
70 passwd= self.genpasswd()
71- out+= partner.email + ',' + passwd + '\n'
72 mail= record['mail'] % {'login' : partner.email, 'passwd' : passwd, 'name' : partner.name}
73 if record['send_mail']:
74 vals = {

Subscribers

People subscribed via source and target branches

to all changes: