diff options
| author | Stephane Wirtel <stw@openerp.com> | 2011-09-13 16:00:16 +0200 |
|---|---|---|
| committer | Stephane Wirtel <stw@openerp.com> | 2011-09-13 16:00:16 +0200 |
| commit | 2a59ce92e3ea35cca00a314d44556b522b3c2fa8 (patch) | |
| tree | 6e7eec2157a513284e6740a95f2e39b7f04aef79 /addons/project_scrum | |
| parent | 8a2bc42c3c45b4d3c94070a29fa76636256f3da7 (diff) | |
| parent | 2a40f9a4997eecc6f997ab0e43dc6334263b9cad (diff) | |
[MERGE] Email Framework - lp:~openerp-dev/openobject-addons/trunk-emails-unified
bzr revid: stw@openerp.com-20110913140016-zzfynrnjdaap0tfb
Diffstat (limited to 'addons/project_scrum')
| -rw-r--r-- | addons/project_scrum/__openerp__.py | 4 | ||||
| -rw-r--r-- | addons/project_scrum/project_scrum.py | 3 | ||||
| -rw-r--r-- | addons/project_scrum/project_scrum_view.xml | 6 | ||||
| -rw-r--r-- | addons/project_scrum/wizard/__init__.py | 2 | ||||
| -rw-r--r-- | addons/project_scrum/wizard/mail_compose_message.py | 65 | ||||
| -rw-r--r-- | addons/project_scrum/wizard/project_scrum_email.py | 8 |
6 files changed, 78 insertions, 10 deletions
diff --git a/addons/project_scrum/__openerp__.py b/addons/project_scrum/__openerp__.py index 9a1713b9014..9b2f4c4e046 100644 --- a/addons/project_scrum/__openerp__.py +++ b/addons/project_scrum/__openerp__.py @@ -50,7 +50,7 @@ More information on the methodology: """, 'author': 'OpenERP SA', 'images': ['images/product_backlogs.jpeg', 'images/project_sprints.jpeg', 'images/scrum_dashboard.jpeg', 'images/scrum_meetings.jpeg'], - 'depends': ['project', 'process'], + 'depends': ['project', 'process', 'mail'], 'init_xml': [], 'update_xml': [ 'security/ir.model.access.csv', @@ -58,7 +58,7 @@ More information on the methodology: 'wizard/project_scrum_backlog_create_task_view.xml', 'wizard/project_scrum_backlog_merger_view.xml', 'wizard/project_scrum_postpone_view.xml', - "wizard/project_scrum_email_view.xml", +# "wizard/project_scrum_email_view.xml", 'project_scrum_view.xml', 'wizard/project_scrum_backlog_sprint_view.xml', 'process/project_scrum_process.xml', diff --git a/addons/project_scrum/project_scrum.py b/addons/project_scrum/project_scrum.py index 334a415982d..f0db98294e7 100644 --- a/addons/project_scrum/project_scrum.py +++ b/addons/project_scrum/project_scrum.py @@ -317,6 +317,7 @@ class project_scrum_meeting(osv.osv): return True def email_send(self, cr, uid, ids, email, context=None): + mail_message_obj = self.pool.get('mail.message') meeting_id = self.browse(cr, uid, ids, context=context)[0] user = self.pool.get('res.users').browse(cr, uid, uid, context=context) user_email = user.user_email or tools.config.get('email_from', False) @@ -324,7 +325,7 @@ class project_scrum_meeting(osv.osv): body += _('\n* Tasks since yesterday:\n_______________________\n%s\n\n* Task for Today:\n_______________________ \n%s\n\n* Blocks encountered:\n_______________________ \n\n%s') %(meeting_id.question_yesterday,meeting_id.question_today, meeting_id.question_blocks or _('No Blocks')) body += _("\n\nThank you,\n%s") % user.name sub_name = meeting_id.name or _('Scrum Meeting of %s') % meeting_id.date - flag = tools.email_send(user_email , [email], sub_name, body, reply_to=None, openobject_id=str(meeting_id.id)) + flag = mail_message_obj.schedule_with_attach(cr, uid, user_email , [email], sub_name, body, model='project.scrum.meeting', res_id=meeting_id.id, context=context) if not flag: return False return True diff --git a/addons/project_scrum/project_scrum_view.xml b/addons/project_scrum/project_scrum_view.xml index 18421b784c3..19d1bcc6b84 100644 --- a/addons/project_scrum/project_scrum_view.xml +++ b/addons/project_scrum/project_scrum_view.xml @@ -302,7 +302,7 @@ </notebook> <group col="8" colspan="4"> <field name="state" readonly="1"/> - <button name="%(project_scrum.report_scrum_sprint_burndown_chart)d" + <button name="%(project_scrum.report_scrum_sprint_burndown_chart)d" string="Burndown Chart" type="action" icon="gtk-print"/> <button type="object" string="Open" name="button_open" states="draft,pending" icon="terp-camera_test"/> <button type="object" string="Pending" name="button_pending" states="open" icon="gtk-media-pause"/> @@ -396,7 +396,9 @@ <field name="date"/> <field name="sprint_id" domain="[('state', '=', 'open')]"/> <field name="user_id"/> - <button name="%(action_project_scrum_email)d" string="Send Email" type="action" icon="terp-mail-message-new" /> + <button name="%(mail.action_email_compose_message_wizard)d" + string="Send Email" type="action" icon="terp-mail-message-new" + /> </group> <notebook colspan="4"> <page string="Scrum Meeting"> diff --git a/addons/project_scrum/wizard/__init__.py b/addons/project_scrum/wizard/__init__.py index 4b5b0919574..fcba1742d75 100644 --- a/addons/project_scrum/wizard/__init__.py +++ b/addons/project_scrum/wizard/__init__.py @@ -23,7 +23,7 @@ import project_scrum_backlog_create_task import project_scrum_backlog_sprint import project_scrum_backlog_merger import project_scrum_postpone -import project_scrum_email +import mail_compose_message # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project_scrum/wizard/mail_compose_message.py b/addons/project_scrum/wizard/mail_compose_message.py new file mode 100644 index 00000000000..777ca03fa37 --- /dev/null +++ b/addons/project_scrum/wizard/mail_compose_message.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from osv import osv +from osv import fields +from tools.translate import _ + +class mail_compose_message(osv.osv_memory): + _inherit = 'mail.compose.message' + + def get_value(self, cr, uid, model, resource_id, context=None): + ''' + To get values of the resource_id for the model + @param model: Object + @param resource_id: id of a record for which values to be read + + @return: Returns a dictionary + ''' + if context is None: + context = {} + result = super(mail_compose_message, self).get_value(cr, uid, model, resource_id, context=context) + if model == 'project.scrum.meeting' and resource_id: + meeting_pool = self.pool.get('project.scrum.meeting') + user_pool = self.pool.get('res.users') + meeting = meeting_pool.browse(cr, uid, resource_id, context=context) + + sprint = meeting.sprint_id + user_data = user_pool.browse(cr, uid, uid, context=context) + result.update({'email_from': user_data.address_id and user_data.address_id.email or False}) + + if sprint.scrum_master_id and sprint.scrum_master_id.user_email: + result.update({'email_to': sprint.scrum_master_id.user_email}) + if sprint.product_owner_id and sprint.product_owner_id.user_email: + result.update({'email_to': result.get('email_to',False) and result.get('email_to') + ',' + sprint.product_owner_id.user_email or sprint.product_owner_id.user_email}) + + subject = _("Scrum Meeting : %s") %(meeting.date) + message = _("Hello , \nI am sending you Scrum Meeting : %s for the Sprint '%s' of Project '%s'") %(meeting.date, sprint.name, sprint.project_id.name) + result.update({ + 'subject': subject, + 'body_text': message, + 'model': model, + 'res_id': resource_id + }) + return result + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/project_scrum/wizard/project_scrum_email.py b/addons/project_scrum/wizard/project_scrum_email.py index f2e8dd79446..f1d5b6665f7 100644 --- a/addons/project_scrum/wizard/project_scrum_email.py +++ b/addons/project_scrum/wizard/project_scrum_email.py @@ -69,6 +69,7 @@ class project_scrum_email(osv.osv_memory): if context is None: context = {} + mail_message = self.pool.get('mail.message') active_id = context.get('active_id', False) scrum_meeting_pool = self.pool.get('project.scrum.meeting') user_pool = self.pool.get('res.users') @@ -91,7 +92,7 @@ class project_scrum_email(osv.osv_memory): body += "\n%s\n" %_("Task for Today") body += "_______________________ \n" body += "\n%s\n" %(meeting.question_today or _('None')) - body += "\n%s\n" % _('Blocking points encountered:') + body += "\n%s\n" % _('Blocking points encountered:') body += "_______________________ \n" body += "\n%s\n" %(meeting.question_blocks or _('None')) body += "\n%s\n%s" %(_('Thank you,'), user.name) @@ -100,8 +101,7 @@ class project_scrum_email(osv.osv_memory): if data.scrum_master_email == data.product_owner_email: data.product_owner_email = False if data.scrum_master_email: - tools.email_send(user_email, [data.scrum_master_email], data.subject, body, reply_to=user_email) + mail_message.schedule_with_attach(cr, uid, user_email, [data.scrum_master_email], data.subject, body, reply_to=user_email, context=context) if data.product_owner_email: - tools.email_send(user_email, [data.product_owner_email], data.subject, body, reply_to=user_email) + mail_message.schedule_with_attach(cr, uid, user_email, [data.product_owner_email], data.subject, body, reply_to=user_email, context=context) return {'type': 'ir.actions.act_window_close'} -project_scrum_email() |
