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
=== modified file 'mail/mail_mail.py'
--- mail/mail_mail.py 2013-10-18 14:49:24 +0000
+++ mail/mail_mail.py 2013-11-13 12:20:23 +0000
@@ -30,6 +30,7 @@
30from openerp.addons.base.ir.ir_mail_server import MailDeliveryException30from openerp.addons.base.ir.ir_mail_server import MailDeliveryException
31from openerp.osv import fields, osv31from openerp.osv import fields, osv
32from openerp.tools.translate import _32from openerp.tools.translate import _
33import openerp.tools as tools
3334
34_logger = logging.getLogger(__name__)35_logger = logging.getLogger(__name__)
3536
@@ -62,6 +63,7 @@
62 # and during unlink() we will not cascade delete the parent and its attachments63 # and during unlink() we will not cascade delete the parent and its attachments
63 'notification': fields.boolean('Is Notification',64 'notification': fields.boolean('Is Notification',
64 help='Mail has been created to notify people of an existing mail.message'),65 help='Mail has been created to notify people of an existing mail.message'),
66 'failure_reason': fields.text('Failure Reason', help="Show reason of failed mail"),
65 }67 }
6668
67 _defaults = {69 _defaults = {
@@ -286,7 +288,7 @@
286 mail.write({'state': 'sent', 'message_id': res})288 mail.write({'state': 'sent', 'message_id': res})
287 mail_sent = True289 mail_sent = True
288 else:290 else:
289 mail.write({'state': 'exception'})291 mail.write({'state': 'exception', 'failure_reason': _('Recipient is not specified.')})
290 mail_sent = False292 mail_sent = False
291293
292 # /!\ can't use mail.state here, as mail.refresh() will cause an error294 # /!\ can't use mail.state here, as mail.refresh() will cause an error
@@ -294,8 +296,9 @@
294 if mail_sent:296 if mail_sent:
295 self._postprocess_sent_message(cr, uid, mail, context=context)297 self._postprocess_sent_message(cr, uid, mail, context=context)
296 except Exception as e:298 except Exception as e:
297 _logger.exception('failed sending mail.mail %s', mail.id)299 failure_reason = tools.ustr(e)
298 mail.write({'state': 'exception'})300 _logger.exception('failed sending mail.mail %s due to %s', mail.id, failure_reason)
301 mail.write({'state': 'exception', 'failure_reason': failure_reason})
299 if raise_exception:302 if raise_exception:
300 if isinstance(e, AssertionError):303 if isinstance(e, AssertionError):
301 # get the args of the original error, wrap into a value and throw a MailDeliveryException304 # get the args of the original error, wrap into a value and throw a MailDeliveryException
302305
=== modified file 'mail/mail_mail_view.xml'
--- mail/mail_mail_view.xml 2013-09-13 11:54:08 +0000
+++ mail/mail_mail_view.xml 2013-11-13 12:20:23 +0000
@@ -25,6 +25,7 @@
25 <field name="recipient_ids" widget="many2many_tags"/>25 <field name="recipient_ids" widget="many2many_tags"/>
26 <field name="email_cc"/>26 <field name="email_cc"/>
27 <field name="reply_to"/>27 <field name="reply_to"/>
28 <field name="failure_reason"/>
28 </group>29 </group>
29 <notebook>30 <notebook>
30 <page string="Body">31 <page string="Body">
@@ -71,6 +72,7 @@
71 <field name="date"/>72 <field name="date"/>
72 <field name="subject"/>73 <field name="subject"/>
73 <field name="author_id" string="User"/>74 <field name="author_id" string="User"/>
75 <field name="failure_reason"/>
74 <field name="message_id" invisible="1"/>76 <field name="message_id" invisible="1"/>
75 <field name="recipient_ids" invisible="1"/>77 <field name="recipient_ids" invisible="1"/>
76 <field name="model" invisible="1"/>78 <field name="model" invisible="1"/>
7779
=== modified file 'mail/mail_message_view.xml'
--- mail/mail_message_view.xml 2013-08-29 10:09:32 +0000
+++ mail/mail_message_view.xml 2013-11-13 12:20:23 +0000
@@ -10,6 +10,7 @@
10 <tree string="Messages">10 <tree string="Messages">
11 <field name="date"/>11 <field name="date"/>
12 <field name="subject"/>12 <field name="subject"/>
13 <field name="type" invisible="1"/>
13 <field name="author_id"/>14 <field name="author_id"/>
14 <field name="model"/>15 <field name="model"/>
15 <field name="res_id"/>16 <field name="res_id"/>
1617
=== modified file 'mail/res_config.py'
--- mail/res_config.py 2013-09-17 10:20:46 +0000
+++ mail/res_config.py 2013-11-13 12:20:23 +0000
@@ -20,10 +20,11 @@
20##############################################################################20##############################################################################
2121
22import urlparse22import urlparse
2323from lxml import etree
24import datetime
25from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
24from openerp.osv import osv, fields26from openerp.osv import osv, fields
2527
26
27class project_configuration(osv.TransientModel):28class project_configuration(osv.TransientModel):
28 _inherit = 'base.config.settings'29 _inherit = 'base.config.settings'
2930
@@ -33,6 +34,32 @@
33 "the OpenERP server, enter the domain name here."),34 "the OpenERP server, enter the domain name here."),
34 }35 }
3536
37 def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
38 """
39 Overrides orm field_view_get.
40 """
41 res = {}
42 res = super(project_configuration, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type,context=context, toolbar=toolbar, submenu=submenu)
43 doc = etree.XML(res['arch'])
44 previous_date = datetime.datetime.now() - datetime.timedelta(hours=24)
45 mail_xml_ids = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'action_view_mail_mail_exception')
46 mail_ids = self.pool.get('mail.mail').search(cr, uid, [('date', '>=', previous_date.strftime( DEFAULT_SERVER_DATETIME_FORMAT)), ('state', '=', 'exception')], context=context)
47 if mail_ids:
48 xml_div_failure_element = etree.Element("span")
49 xml_div_failure_element.set('class','failure_mail_list')
50 xml_button_element = etree.Element("button")
51 xml_button_element.set("name", str(mail_xml_ids and mail_xml_ids[1] or False))
52 xml_button_element.set("string", "%s %s Email(s) not sent"%(u"\u26A0",len(mail_ids)))
53 xml_button_element.set("type", "action")
54 xml_button_element.set("class", "oe_link oe_highlight_link oe_change-from-text")
55 #structure Elements
56 xml_div_failure_element.append(xml_button_element)
57 div_email_node = doc.xpath("//div[@name='email']")
58 if div_email_node and len(div_email_node)>0:
59 div_email_node[0][0].append(xml_div_failure_element)
60 res['arch'] = etree.tostring(doc)
61 return res
62
36 def get_default_alias_domain(self, cr, uid, ids, context=None):63 def get_default_alias_domain(self, cr, uid, ids, context=None):
37 alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)64 alias_domain = self.pool.get("ir.config_parameter").get_param(cr, uid, "mail.catchall.domain", context=context)
38 if not alias_domain:65 if not alias_domain:
3966
=== modified file 'mail/res_config_view.xml'
--- mail/res_config_view.xml 2013-09-13 11:54:08 +0000
+++ mail/res_config_view.xml 2013-11-13 12:20:23 +0000
@@ -1,6 +1,14 @@
1<?xml version="1.0" encoding="utf-8"?>1<?xml version="1.0" encoding="utf-8"?>
2<openerp>2<openerp>
3 <data>3 <data>
4 <record id="action_view_mail_mail_exception" model="ir.actions.act_window">
5 <field name="name">Emails</field>
6 <field name="res_model">mail.mail</field>
7 <field name="view_type">form</field>
8 <field name="view_mode">tree,form</field>
9 <field name="context">{'search_default_exception': 1}</field>
10 </record>
11
4 <record id="view_general_configuration_mail_alias_domain" model="ir.ui.view">12 <record id="view_general_configuration_mail_alias_domain" model="ir.ui.view">
5 <field name="name">base.config.settings.mail.alias</field>13 <field name="name">base.config.settings.mail.alias</field>
6 <field name="model">base.config.settings</field>14 <field name="model">base.config.settings</field>
715
=== modified file 'mail/static/src/css/mail.css'
--- mail/static/src/css/mail.css 2013-08-12 04:38:10 +0000
+++ mail/static/src/css/mail.css 2013-11-13 12:20:23 +0000
@@ -53,6 +53,12 @@
53.openerp .oe_mail > .oe_thread{53.openerp .oe_mail > .oe_thread{
54 margin-left: 0px;54 margin-left: 0px;
55}55}
56.openerp .oe_button.oe_link.oe_highlight_link span {
57 color: red;
58}
59.openerp .oe_form_configuration .oe_form_group td:last-child .oe_change-from-text:before{
60 content:" ";
61}
56.openerp .oe_inline.oe_compose_recipients {62.openerp .oe_inline.oe_compose_recipients {
57 margin-top: -2px;63 margin-top: -2px;
58}64}
5965
=== modified file 'mail/tests/test_mail_features.py'
--- mail/tests/test_mail_features.py 2013-10-18 14:49:24 +0000
+++ mail/tests/test_mail_features.py 2013-11-13 12:20:23 +0000
@@ -524,7 +524,6 @@
524 msg_pids = [partner.id for partner in msg.notified_partner_ids]524 msg_pids = [partner.id for partner in msg.notified_partner_ids]
525 msg_aids = [attach.id for attach in msg.attachment_ids]525 msg_aids = [attach.id for attach in msg.attachment_ids]
526 sent_emails = self._build_email_kwargs_list526 sent_emails = self._build_email_kwargs_list
527
528 # Test: mail_message: subject is False, body, parent_id is msg_id527 # Test: mail_message: subject is False, body, parent_id is msg_id
529 self.assertEqual(msg.subject, False, 'message_post: mail.message subject incorrect')528 self.assertEqual(msg.subject, False, 'message_post: mail.message subject incorrect')
530 self.assertEqual(msg.body, html_sanitize(_body2), 'message_post: mail.message body incorrect')529 self.assertEqual(msg.body, html_sanitize(_body2), 'message_post: mail.message body incorrect')
@@ -638,7 +637,6 @@
638 'default_res_id': self.group_pigs_id,637 'default_res_id': self.group_pigs_id,
639 })638 })
640 compose = mail_compose.browse(cr, uid, compose_id)639 compose = mail_compose.browse(cr, uid, compose_id)
641
642 # Test: mail.compose.message: composition_mode, model, res_id640 # Test: mail.compose.message: composition_mode, model, res_id
643 self.assertEqual(compose.composition_mode, 'comment', 'compose wizard: mail.compose.message incorrect composition_mode')641 self.assertEqual(compose.composition_mode, 'comment', 'compose wizard: mail.compose.message incorrect composition_mode')
644 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')642 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
@@ -648,7 +646,8 @@
648 mail_compose.send_mail(cr, user_raoul.id, [compose_id], {'mail_post_autofollow': True, 'mail_create_nosubscribe': True})646 mail_compose.send_mail(cr, user_raoul.id, [compose_id], {'mail_post_autofollow': True, 'mail_create_nosubscribe': True})
649 group_pigs.refresh()647 group_pigs.refresh()
650 message = group_pigs.message_ids[0]648 message = group_pigs.message_ids[0]
651649 # Test: mail_mail: notifications have been deleted
650 self.assertFalse(self.mail_mail.search(cr, uid, [('mail_message_id', '=', message.id)]),'message_send: mail.mail message should have been auto-deleted!')
652 # Test: mail.group: followers (c and d added by auto follow key; raoul not added by nosubscribe key)651 # Test: mail.group: followers (c and d added by auto follow key; raoul not added by nosubscribe key)
653 pigs_pids = [p.id for p in group_pigs.message_follower_ids]652 pigs_pids = [p.id for p in group_pigs.message_follower_ids]
654 test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]653 test_pids = [self.partner_admin_id, p_b_id, p_c_id, p_d_id]
@@ -679,7 +678,6 @@
679 'default_parent_id': message.id678 'default_parent_id': message.id
680 })679 })
681 compose = mail_compose.browse(cr, uid, compose_id)680 compose = mail_compose.browse(cr, uid, compose_id)
682
683 # Test: mail.compose.message: model, res_id, parent_id681 # Test: mail.compose.message: model, res_id, parent_id
684 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')682 self.assertEqual(compose.model, 'mail.group', 'compose wizard: mail.compose.message incorrect model')
685 self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id')683 self.assertEqual(compose.res_id, self.group_pigs_id, 'compose wizard: mail.compose.message incorrect res_id')
@@ -725,6 +723,12 @@
725723
726 # Test: Pigs and Bird did receive their message724 # Test: Pigs and Bird did receive their message
727 test_msg_ids = self.mail_message.search(cr, uid, [], limit=2)725 test_msg_ids = self.mail_message.search(cr, uid, [], limit=2)
726 mail_ids = self.mail_mail.search(cr, uid, [('mail_message_id', '=', message2.id)])
727 mail_record_id = self.mail_mail.browse(cr, uid, mail_ids)[0]
728 self.assertTrue(mail_record_id, "'message_send: mail.mail message should have in processing mail queue'" )
729 #check mass mail state...
730 test_mail_ids = self.mail_mail.search(cr, uid, [('state', '=', 'exception')])
731 self.assertNotIn(mail_ids, test_mail_ids, 'compose wizard: Mail sending Failed!!')
728 self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message')732 self.assertIn(message1.id, test_msg_ids, 'compose wizard: Pigs did not receive its mass mailing message')
729 self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message')733 self.assertIn(message2.id, test_msg_ids, 'compose wizard: Bird did not receive its mass mailing message')
730734
731735
=== modified file 'marketing_campaign/marketing_campaign.py'
--- marketing_campaign/marketing_campaign.py 2013-04-15 10:23:49 +0000
+++ marketing_campaign/marketing_campaign.py 2013-11-13 12:20:23 +0000
@@ -30,6 +30,7 @@
30from openerp.tools.safe_eval import safe_eval as eval30from openerp.tools.safe_eval import safe_eval as eval
31import re31import re
32from openerp.addons.decimal_precision import decimal_precision as dp32from openerp.addons.decimal_precision import decimal_precision as dp
33from openerp import netsvc
3334
34from openerp.osv import fields, osv35from openerp.osv import fields, osv
35from openerp.tools.translate import _36from openerp.tools.translate import _

Subscribers

People subscribed via source and target branches

to all changes: