Merge lp:~openerp-dev/openobject-addons/trunk-send_mail_warning-nco into lp:openobject-addons

Proposed by Harry (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-send_mail_warning-nco
Merge into: lp:openobject-addons
Diff against target: 222 lines (+61/-9)
8 files modified
mail/mail_mail.py (+6/-3)
mail/mail_mail_view.xml (+2/-0)
mail/mail_message_view.xml (+1/-0)
mail/res_config.py (+29/-2)
mail/res_config_view.xml (+8/-0)
mail/static/src/css/mail.css (+6/-0)
mail/tests/test_mail_features.py (+8/-4)
marketing_campaign/marketing_campaign.py (+1/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-send_mail_warning-nco
Reviewer Review Type Date Requested Status
Thibault Delavallée (OpenERP) (community) Needs Fixing
Atul Patel(OpenERP) (community) Needs Resubmitting
Mustufa Rangwala (Open ERP) (community) Needs Fixing
Review via email: mp+176639@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mustufa Rangwala (Open ERP) (mra-tinyerp) wrote :

Thanks for the proposal.. Please check below points.

- Line 153-156 => Merge lines by giving Email(s)
- Keep default value for raise_exception in line 24 with True
- field: failure_reason -> Improve tooltip (Show exception..)

Regards,

review: Needs Fixing
Revision history for this message
Atul Patel(OpenERP) (atp-openerp) wrote :

Hello sir,

Improve code as per ur suggestion..
Thanks

review: Needs Resubmitting
8829. By Pariket Trivedi(OpenERP)

[IMP] : for general setting email failer worring change.

8830. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8831. By Pariket Trivedi(OpenERP)

[Fix]: Email in Groupby field 'type' and marketting campaign remove send email exception.

8832. By Pariket Trivedi(OpenERP)

[IMP] email groupby 'type' field invisible

8833. By Atul Patel(OpenERP)

[MERGE]: Merged with trunk

8834. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8835. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8836. By Atul Patel(OpenERP)

[MERGE]: Merged trunk-addons

Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

What's the purpose of the fields_view_get override ?

review: Needs Information
Revision history for this message
Atul Patel(OpenERP) (atp-openerp) wrote :

Hello Thaibault,

In General configuration setting, we required number of failed emails count.
to find that number of failed emails not sent and to display that in configuration we override fields_view_get method.

Thanks

Revision history for this message
Thibault Delavallée (OpenERP) (tde-openerp) wrote :

Hello,

Long time, but back to goold ol' stuff! About the override of fields view get, it seems complicated. You could obtain the same result with standard fields and view. I think you should define a new function field in the config. It computes the number of failed emails. In the config view, display the number of failed emails + link to the action.

Moreover, limiting to the last 24 hours seems short. I would prefer seeing the last 30 days.

review: Needs Fixing

Unmerged revisions

8836. By Atul Patel(OpenERP)

[MERGE]: Merged trunk-addons

8835. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8834. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8833. By Atul Patel(OpenERP)

[MERGE]: Merged with trunk

8832. By Pariket Trivedi(OpenERP)

[IMP] email groupby 'type' field invisible

8831. By Pariket Trivedi(OpenERP)

[Fix]: Email in Groupby field 'type' and marketting campaign remove send email exception.

8830. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8829. By Pariket Trivedi(OpenERP)

[IMP] : for general setting email failer worring change.

8828. By Atul Patel(OpenERP)

[MERGE]: Merged with addons

8827. By Atul Patel(OpenERP)

[ADD]: Add new action in config file for mail exception

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mail/mail_mail.py'
2--- mail/mail_mail.py 2013-10-18 14:49:24 +0000
3+++ mail/mail_mail.py 2013-11-13 12:20:23 +0000
4@@ -30,6 +30,7 @@
5 from openerp.addons.base.ir.ir_mail_server import MailDeliveryException
6 from openerp.osv import fields, osv
7 from openerp.tools.translate import _
8+import openerp.tools as tools
9
10 _logger = logging.getLogger(__name__)
11
12@@ -62,6 +63,7 @@
13 # and during unlink() we will not cascade delete the parent and its attachments
14 'notification': fields.boolean('Is Notification',
15 help='Mail has been created to notify people of an existing mail.message'),
16+ 'failure_reason': fields.text('Failure Reason', help="Show reason of failed mail"),
17 }
18
19 _defaults = {
20@@ -286,7 +288,7 @@
21 mail.write({'state': 'sent', 'message_id': res})
22 mail_sent = True
23 else:
24- mail.write({'state': 'exception'})
25+ mail.write({'state': 'exception', 'failure_reason': _('Recipient is not specified.')})
26 mail_sent = False
27
28 # /!\ can't use mail.state here, as mail.refresh() will cause an error
29@@ -294,8 +296,9 @@
30 if mail_sent:
31 self._postprocess_sent_message(cr, uid, mail, context=context)
32 except Exception as e:
33- _logger.exception('failed sending mail.mail %s', mail.id)
34- mail.write({'state': 'exception'})
35+ failure_reason = tools.ustr(e)
36+ _logger.exception('failed sending mail.mail %s due to %s', mail.id, failure_reason)
37+ mail.write({'state': 'exception', 'failure_reason': failure_reason})
38 if raise_exception:
39 if isinstance(e, AssertionError):
40 # get the args of the original error, wrap into a value and throw a MailDeliveryException
41
42=== modified file 'mail/mail_mail_view.xml'
43--- mail/mail_mail_view.xml 2013-09-13 11:54:08 +0000
44+++ mail/mail_mail_view.xml 2013-11-13 12:20:23 +0000
45@@ -25,6 +25,7 @@
46 <field name="recipient_ids" widget="many2many_tags"/>
47 <field name="email_cc"/>
48 <field name="reply_to"/>
49+ <field name="failure_reason"/>
50 </group>
51 <notebook>
52 <page string="Body">
53@@ -71,6 +72,7 @@
54 <field name="date"/>
55 <field name="subject"/>
56 <field name="author_id" string="User"/>
57+ <field name="failure_reason"/>
58 <field name="message_id" invisible="1"/>
59 <field name="recipient_ids" invisible="1"/>
60 <field name="model" invisible="1"/>
61
62=== modified file 'mail/mail_message_view.xml'
63--- mail/mail_message_view.xml 2013-08-29 10:09:32 +0000
64+++ mail/mail_message_view.xml 2013-11-13 12:20:23 +0000
65@@ -10,6 +10,7 @@
66 <tree string="Messages">
67 <field name="date"/>
68 <field name="subject"/>
69+ <field name="type" invisible="1"/>
70 <field name="author_id"/>
71 <field name="model"/>
72 <field name="res_id"/>
73
74=== modified file 'mail/res_config.py'
75--- mail/res_config.py 2013-09-17 10:20:46 +0000
76+++ mail/res_config.py 2013-11-13 12:20:23 +0000
77@@ -20,10 +20,11 @@
78 ##############################################################################
79
80 import urlparse
81-
82+from lxml import etree
83+import datetime
84+from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
85 from openerp.osv import osv, fields
86
87-
88 class project_configuration(osv.TransientModel):
89 _inherit = 'base.config.settings'
90
91@@ -33,6 +34,32 @@
92 "the OpenERP server, enter the domain name here."),
93 }
94
95+ def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
96+ """
97+ Overrides orm field_view_get.
98+ """
99+ res = {}
100+ res = super(project_configuration, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type,context=context, toolbar=toolbar, submenu=submenu)
101+ doc = etree.XML(res['arch'])
102+ previous_date = datetime.datetime.now() - datetime.timedelta(hours=24)
103+ mail_xml_ids = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'action_view_mail_mail_exception')
104+ mail_ids = self.pool.get('mail.mail').search(cr, uid, [('date', '>=', previous_date.strftime( DEFAULT_SERVER_DATETIME_FORMAT)), ('state', '=', 'exception')], context=context)
105+ if mail_ids:
106+ xml_div_failure_element = etree.Element("span")
107+ xml_div_failure_element.set('class','failure_mail_list')
108+ xml_button_element = etree.Element("button")
109+ xml_button_element.set("name", str(mail_xml_ids and mail_xml_ids[1] or False))
110+ xml_button_element.set("string", "%s %s Email(s) not sent"%(u"\u26A0",len(mail_ids)))
111+ xml_button_element.set("type", "action")
112+ xml_button_element.set("class", "oe_link oe_highlight_link oe_change-from-text")
113+ #structure Elements
114+ xml_div_failure_element.append(xml_button_element)
115+ div_email_node = doc.xpath("//div[@name='email']")
116+ if div_email_node and len(div_email_node)>0:
117+ div_email_node[0][0].append(xml_div_failure_element)
118+ res['arch'] = etree.tostring(doc)
119+ return res
120+
121 def get_default_alias_domain(self, cr, uid, ids, context=None):
122 alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
123 if not alias_domain:
124
125=== modified file 'mail/res_config_view.xml'
126--- mail/res_config_view.xml 2013-09-13 11:54:08 +0000
127+++ mail/res_config_view.xml 2013-11-13 12:20:23 +0000
128@@ -1,6 +1,14 @@
129 <?xml version="1.0" encoding="utf-8"?>
130 <openerp>
131 <data>
132+ <record id="action_view_mail_mail_exception" model="ir.actions.act_window">
133+ <field name="name">Emails</field>
134+ <field name="res_model">mail.mail</field>
135+ <field name="view_type">form</field>
136+ <field name="view_mode">tree,form</field>
137+ <field name="context">{'search_default_exception': 1}</field>
138+ </record>
139+
140 <record id="view_general_configuration_mail_alias_domain" model="ir.ui.view">
141 <field name="name">base.config.settings.mail.alias</field>
142 <field name="model">base.config.settings</field>
143
144=== modified file 'mail/static/src/css/mail.css'
145--- mail/static/src/css/mail.css 2013-08-12 04:38:10 +0000
146+++ mail/static/src/css/mail.css 2013-11-13 12:20:23 +0000
147@@ -53,6 +53,12 @@
148 .openerp .oe_mail > .oe_thread{
149 margin-left: 0px;
150 }
151+.openerp .oe_button.oe_link.oe_highlight_link span {
152+ color: red;
153+}
154+.openerp .oe_form_configuration .oe_form_group td:last-child .oe_change-from-text:before{
155+ content:" ";
156+}
157 .openerp .oe_inline.oe_compose_recipients {
158 margin-top: -2px;
159 }
160
161=== modified file 'mail/tests/test_mail_features.py'
162--- mail/tests/test_mail_features.py 2013-10-18 14:49:24 +0000
163+++ mail/tests/test_mail_features.py 2013-11-13 12:20:23 +0000
164@@ -524,7 +524,6 @@
165 msg_pids = [partner.id for partner in msg.notified_partner_ids]
166 msg_aids = [attach.id for attach in msg.attachment_ids]
167 sent_emails = self._build_email_kwargs_list
168-
169 # Test: mail_message: subject is False, body, parent_id is msg_id
170 self.assertEqual(msg.subject, False, 'message_post: mail.message subject incorrect')
171 self.assertEqual(msg.body, html_sanitize(_body2), 'message_post: mail.message body incorrect')
172@@ -638,7 +637,6 @@
173 'default_res_id': self.group_pigs_id,
174 })
175 compose = mail_compose.browse(cr, uid, compose_id)
176-
177 # Test: mail.compose.message: composition_mode, model, res_id
178 self.assertEqual(compose.composition_mode, 'comment', 'compose wizard: mail.compose.message incorrect composition_mode')
179 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
180@@ -648,7 +646,8 @@
181 mail_compose.send_mail(cr, user_raoul.id, [compose_id], {'mail_post_autofollow': True, 'mail_create_nosubscribe': True})
182 group_pigs.refresh()
183 message = group_pigs.message_ids[0]
184-
185+ # Test: mail_mail: notifications have been deleted
186+ self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', message.id)]),'message_send: mail.mail message should have been auto-deleted!')
187 # Test: mail.group: followers (c and d added by auto follow key; raoul not added by nosubscribe key)
188 pigs_pids = [p.id for p in group_pigs.message_follower_ids]
189 test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]
190@@ -679,7 +678,6 @@
191 'default_parent_id': message.id
192 })
193 compose = mail_compose.browse(cr, uid, compose_id)
194-
195 # Test: mail.compose.message: model, res_id, parent_id
196 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
197 self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id')
198@@ -725,6 +723,12 @@
199
200 # Test: Pigs and Bird did receive their message
201 test_msg_ids = self.mail_message.search(cr, uid, [], limit=2)
202+ mail_ids = self.mail_mail.search(cr, uid, [('mail_message_id', '=', message2.id)])
203+ mail_record_id = self.mail_mail.browse(cr, uid, mail_ids)[0]
204+ self.assertTrue(mail_record_id, "'message_send: mail.mail message should have in processing mail queue'" )
205+ #check mass mail state...
206+ test_mail_ids = self.mail_mail.search(cr, uid, [('state', '=', 'exception')])
207+ self.assertNotIn(mail_ids, test_mail_ids, 'compose wizard: Mail sending Failed!!')
208 self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message')
209 self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message')
210
211
212=== modified file 'marketing_campaign/marketing_campaign.py'
213--- marketing_campaign/marketing_campaign.py 2013-04-15 10:23:49 +0000
214+++ marketing_campaign/marketing_campaign.py 2013-11-13 12:20:23 +0000
215@@ -30,6 +30,7 @@
216 from openerp.tools.safe_eval import safe_eval as eval
217 import re
218 from openerp.addons.decimal_precision import decimal_precision as dp
219+from openerp import netsvc
220
221 from openerp.osv import fields, osv
222 from openerp.tools.translate import _

Subscribers

People subscribed via source and target branches

to all changes: