Merge lp:~openerp-commiter/openobject-addons/6.0-opw-4594-dhs into lp:openobject-addons/6.0

Proposed by Dhruti Shastri(OpenERP)
Status: Rejected
Rejected by: Jay Vora (Serpent Consulting Services)
Proposed branch: lp:~openerp-commiter/openobject-addons/6.0-opw-4594-dhs
Merge into: lp:openobject-addons/6.0
Diff against target: 190 lines (+27/-27)
1 file modified
email_template/email_template_account.py (+27/-27)
To merge this branch: bzr merge lp:~openerp-commiter/openobject-addons/6.0-opw-4594-dhs
Reviewer Review Type Date Requested Status
Jay Vora (Serpent Consulting Services) (community) Needs Fixing
Review via email: mp+54210@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Dhruti,

Thanks for the patch, but can you please try to correct the no. of unnecessary lines for the patch?
Moreover, please try to see the relevant lines of code where %(e) has been used,correct them too.

Thanks.

review: Needs Fixing
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Dhruti,

I am rejecting the proposal as this needs corrections and currently not to-the-shoulder to latest addons.

Thanks.

Unmerged revisions

4472. By Dhruti Shastri(OpenERP)

[FIX] email_template : Added tools.ustr to convert the string (Ref : case 4594)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'email_template/email_template_account.py'
2--- email_template/email_template_account.py 2011-01-14 00:11:01 +0000
3+++ email_template/email_template_account.py 2011-03-21 13:43:19 +0000
4@@ -81,10 +81,10 @@
5 size=64, required=True,
6 readonly=True, select=True,
7 help="The description is used as the Sender name along with the provided From Email, \
8-unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
9+unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
10 states={'draft':[('readonly', False)]}),
11- 'auto_delete': fields.boolean('Auto Delete', size=64, readonly=True,
12- help="Permanently delete emails after sending",
13+ 'auto_delete': fields.boolean('Auto Delete', size=64, readonly=True,
14+ help="Permanently delete emails after sending",
15 states={'draft':[('readonly', False)]}),
16 'user':fields.many2one('res.users',
17 'Related User', required=True,
18@@ -112,7 +112,7 @@
19 states={'draft':[('readonly', False)]}),
20 'smtptls':fields.boolean('TLS',
21 states={'draft':[('readonly', False)]}, readonly=True),
22-
23+
24 'smtpssl':fields.boolean('SSL/TLS (only in python 2.6)',
25 states={'draft':[('readonly', False)]}, readonly=True),
26 'send_pref':fields.selection([
27@@ -159,7 +159,7 @@
28 'send_pref':lambda *a: 'html',
29 'smtptls':lambda *a:True,
30 }
31-
32+
33 _sql_constraints = [
34 (
35 'email_uniq',
36@@ -172,9 +172,9 @@
37
38 def _constraint_unique(self, cursor, user, ids, context=None):
39 """
40- This makes sure that you dont give personal
41+ This makes sure that you dont give personal
42 users two accounts with same ID (Validated in sql constaints)
43- However this constraint exempts company accounts.
44+ However this constraint exempts company accounts.
45 Any no of co accounts for a user is allowed
46 """
47 if self.read(cursor, user, ids, ['company'])[0]['company'] == 'no':
48@@ -188,7 +188,7 @@
49 return True
50 else:
51 return True
52-
53+
54 _constraints = [
55 (_constraint_unique,
56 'Error: You are not allowed to have more than 1 account.',
57@@ -198,15 +198,15 @@
58 def get_outgoing_server(self, cursor, user, ids, context=None):
59 """
60 Returns the Out Going Connection (SMTP) object
61-
62+
63 @attention: DO NOT USE except_osv IN THIS METHOD
64 @param cursor: Database Cursor
65 @param user: ID of current user
66- @param ids: ID/list of ids of current object for
67+ @param ids: ID/list of ids of current object for
68 which connection is required
69 First ID will be chosen from lists
70 @param context: Context
71-
72+
73 @return: SMTP server object or Exception
74 """
75 #Type cast ids to integer
76@@ -214,7 +214,7 @@
77 ids = ids[0]
78 this_object = self.browse(cursor, user, ids, context=context)
79 if this_object:
80- if this_object.smtpserver and this_object.smtpport:
81+ if this_object.smtpserver and this_object.smtpport:
82 try:
83 if this_object.smtpssl:
84 serv = smtplib.SMTP_SSL(this_object.smtpserver, this_object.smtpport)
85@@ -234,14 +234,14 @@
86 return serv
87 raise Exception(_("SMTP SERVER or PORT not specified"))
88 raise Exception(_("Core connection for the given ID does not exist"))
89-
90+
91 def check_outgoing_connection(self, cursor, user, ids, context=None):
92 """
93 checks SMTP credentials and confirms if outgoing connection works
94 (Attached to button)
95 @param cursor: Database Cursor
96 @param user: ID of current user
97- @param ids: list of ids of current object for
98+ @param ids: list of ids of current object for
99 which connection is required
100 @param context: Context
101 """
102@@ -253,9 +253,9 @@
103 except Exception, error:
104 raise osv.except_osv(
105 _("Out going connection test failed"),
106- _("Reason: %s") % error
107+ _("Reason: %s") % tools.ustr(error)
108 )
109-
110+
111 def do_approval(self, cr, uid, ids, context=None):
112 #TODO: Check if user has rights
113 self.write(cr, uid, ids, {'state':'approved'}, context=context)
114@@ -279,12 +279,12 @@
115 else:
116 logger.notifyChannel(_("Email Template"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Account not approved") % id)
117 return False
118-
119+
120 #**************************** MAIL SENDING FEATURES ***********************#
121
122
123
124-
125+
126 def send_mail(self, cr, uid, ids, addresses, subject='', body=None, payload=None, message_id=None, context=None):
127 #TODO: Replace all this with a single email object
128 if body is None:
129@@ -294,7 +294,7 @@
130 if context is None:
131 context = {}
132 logger = netsvc.Logger()
133- for id in ids:
134+ for id in ids:
135 core_obj = self.browse(cr, uid, id, context)
136 serv = self.smtp_connection(cr, uid, id)
137 if serv:
138@@ -307,7 +307,7 @@
139 text_part = MIMEMultipart(_subtype=text_subtype)
140 payload_part.attach(text_part)
141 else:
142- # otherwise a single multipart/mixed will do the whole job
143+ # otherwise a single multipart/mixed will do the whole job
144 payload_part = text_part = MIMEMultipart(_subtype=text_subtype)
145
146 if subject:
147@@ -322,7 +322,7 @@
148 payload_part['From'] = sender_name + " <" + core_obj.email_id + ">"
149 payload_part['Organization'] = tools.ustr(core_obj.user.company_id.name)
150 payload_part['Date'] = formatdate()
151- addresses_l = extract_emails_from_dict(addresses)
152+ addresses_l = extract_emails_from_dict(addresses)
153 if addresses_l['To']:
154 payload_part['To'] = u','.join(addresses_l['To'])
155 if addresses_l['CC']:
156@@ -430,28 +430,28 @@
157 e)
158 )
159 return date_as_date
160-
161+
162 def send_receive(self, cr, uid, ids, context=None):
163 for id in ids:
164 ctx = context.copy()
165 ctx['filters'] = [('account_id', '=', id)]
166 self.pool.get('email_template.mailbox').send_all_mail(cr, uid, [], context=ctx)
167 return True
168-
169+
170 def decode_header_text(self, text):
171 """ Decode internationalized headers RFC2822.
172- To, CC, BCC, Subject fields can contain
173+ To, CC, BCC, Subject fields can contain
174 text slices with different encodes, like:
175- =?iso-8859-1?Q?Enric_Mart=ED?= <enricmarti@company.com>,
176+ =?iso-8859-1?Q?Enric_Mart=ED?= <enricmarti@company.com>,
177 =?Windows-1252?Q?David_G=F3mez?= <david@company.com>
178 Sometimes they include extra " character at the beginning/
179 end of the contact name, like:
180 "=?iso-8859-1?Q?Enric_Mart=ED?=" <enricmarti@company.com>
181- and decode_header() does not work well, so we use regular
182+ and decode_header() does not work well, so we use regular
183 expressions (?= ? ? ?=) to split the text slices
184 """
185 if not text:
186- return text
187+ return text
188 p = re.compile("(=\?.*?\?.\?.*?\?=)")
189 text2 = ''
190 try: