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
=== modified file 'survey/wizard/survey_send_invitation.py'
--- survey/wizard/survey_send_invitation.py 2011-10-20 12:37:42 +0000
+++ survey/wizard/survey_send_invitation.py 2012-10-09 12:05:26 +0000
@@ -56,7 +56,7 @@
56 }56 }
5757
58 def genpasswd(self):58 def genpasswd(self):
59 chars = string.letters + string.digits59 chars = string.ascii_letters + string.digits
60 return ''.join([choice(chars) for i in range(6)])60 return ''.join([choice(chars) for i in range(6)])
6161
62 def default_get(self, cr, uid, fields_list, context=None):62 def default_get(self, cr, uid, fields_list, context=None):
@@ -81,7 +81,13 @@
81 if not report_name or not res_ids:81 if not report_name or not res_ids:
82 return (False, Exception('Report name and Resources ids are required !!!'))82 return (False, Exception('Report name and Resources ids are required !!!'))
83 try:83 try:
84 ret_file_name = addons.get_module_resource('survey', 'report') + file_name + '.pdf'84 # Windows: Use %temp% environment variable
85 if os.name == 'nt':
86 tempfolder = os.environ['temp']
87 # Unixoid Oses: user /tmp
88 elif os.name == 'posix':
89 tempfolder = '/tmp'
90 ret_file_name = tempfolder + os.sep + file_name + '.pdf'
85 service = netsvc.LocalService(report_name);91 service = netsvc.LocalService(report_name);
86 (result, format) = service.create(cr, uid, res_ids, {}, {})92 (result, format) = service.create(cr, uid, res_ids, {}, {})
87 fp = open(ret_file_name, 'wb+');93 fp = open(ret_file_name, 'wb+');
@@ -111,7 +117,6 @@
111 act_id = self.pool.get('ir.actions.act_window')117 act_id = self.pool.get('ir.actions.act_window')
112 act_id = act_id.search(cr, uid, [('res_model', '=' , 'survey.name.wiz'), \118 act_id = act_id.search(cr, uid, [('res_model', '=' , 'survey.name.wiz'), \
113 ('view_type', '=', 'form')])119 ('view_type', '=', 'form')])
114 out = "login,password\n"
115 skipped = 0120 skipped = 0
116 existing = ""121 existing = ""
117 created = ""122 created = ""
@@ -125,8 +130,8 @@
125 for use in exist_user:130 for use in exist_user:
126 new_user.append(use.id)131 new_user.append(use.id)
127 for id in survey_ref.browse(cr, uid, survey_ids):132 for id in survey_ref.browse(cr, uid, survey_ids):
128 report = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)133 report, ret_file_name = self.create_report(cr, uid, [id.id], 'report.survey.form', id.title)
129 file = open(addons.get_module_resource('survey', 'report') + id.title +".pdf")134 file = open(ret_file_name)
130 file_data = ""135 file_data = ""
131 while 1:136 while 1:
132 line = file.readline()137 line = file.readline()
@@ -135,7 +140,7 @@
135 break140 break
136 file.close()141 file.close()
137 attachments[id.title +".pdf"] = file_data142 attachments[id.title +".pdf"] = file_data
138 os.remove(addons.get_module_resource('survey', 'report') + id.title +".pdf")143 os.remove(ret_file_name)
139144
140 for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):145 for partner in self.pool.get('res.partner').browse(cr, uid, partner_ids):
141 for addr in partner.address:146 for addr in partner.address:
@@ -158,7 +163,6 @@
158 continue163 continue
159164
160 passwd= self.genpasswd()165 passwd= self.genpasswd()
161 out+= addr.email + ',' + passwd + '\n'
162 mail= record['mail'] % {'login' : addr.email, 'passwd' : passwd, 'name' : addr.name}166 mail= record['mail'] % {'login' : addr.email, 'passwd' : passwd, 'name' : addr.name}
163 if record['send_mail']:167 if record['send_mail']:
164 ans = mail_message.schedule_with_attach(cr, uid, record['mail_from'], [addr.email], \168 ans = mail_message.schedule_with_attach(cr, uid, record['mail_from'], [addr.email], \