From 1487e07364fc926216f3e3126867d8baeae9201c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 7 Sep 2011 19:25:00 +0200 Subject: [PATCH] [IMP] event: spellcheck, simplify mail compose wizard bzr revid: odo@openerp.com-20110907172500-0lxme3pvcwzipeh0 --- addons/event/__openerp__.py | 2 +- addons/event/event.py | 34 ++++++------ addons/event/wizard/__init__.py | 1 - addons/event/wizard/email_compose_message.py | 54 -------------------- 4 files changed, 19 insertions(+), 72 deletions(-) delete mode 100644 addons/event/wizard/email_compose_message.py diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py index cabb980727f..9a9acaf0fb3 100644 --- a/addons/event/__openerp__.py +++ b/addons/event/__openerp__.py @@ -29,7 +29,7 @@ Organization and management of Events. ====================================== -This module allow you +This module allows you * to manage your events and their registrations * to use emails to automatically confirm and send acknowledgements for any registration to an event * ... diff --git a/addons/event/event.py b/addons/event/event.py index 5fba3ec5859..320a48e41f6 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -28,6 +28,8 @@ import decimal_precision as dp from crm import wizard +wizard.mail_compose_message.SUPPORTED_MODELS.append('event.registration') + class event_type(osv.osv): """ Event Type """ _name = 'event.type' @@ -523,30 +525,30 @@ class event_registration(osv.osv): Send email to user """ mail_message = self.pool.get('mail.message') - for regestration in self.browse(cr, uid, ids, context=context): - src = regestration.event_id.reply_to or False + for registration in self.browse(cr, uid, ids, context=context): + src = registration.event_id.reply_to or False email_to = [] email_cc = [] - if regestration.email_from: - email_to = regestration.email_from - if regestration.email_cc: - email_cc += [regestration.email_cc] + if registration.email_from: + email_to = registration.email_from + if registration.email_cc: + email_cc += [registration.email_cc] if not (email_to or email_cc): continue subject = "" body = "" if confirm: - subject = _('Auto Confirmation: [%s] %s') %(regestration.id, regestration.name) - body = regestration.event_id.mail_confirm - elif regestration.event_id.mail_auto_confirm or regestration.event_id.mail_auto_registr: - if regestration.event_id.state in ['draft', 'fixed', 'open', 'confirm', 'running'] and regestration.event_id.mail_auto_registr: - subject = _('Auto Registration: [%s] %s') %(regestration.id, regestration.name) - body = regestration.event_id.mail_registr - if (regestration.event_id.state in ['confirm', 'running']) and regestration.event_id.mail_auto_confirm: - subject = _('Auto Confirmation: [%s] %s') %(regestration.id, regestration.name) - body = regestration.event_id.mail_confirm + subject = _('Auto Confirmation: [%s] %s') %(registration.id, registration.name) + body = registration.event_id.mail_confirm + elif registration.event_id.mail_auto_confirm or registration.event_id.mail_auto_registr: + if registration.event_id.state in ['draft', 'fixed', 'open', 'confirm', 'running'] and registration.event_id.mail_auto_registr: + subject = _('Auto Registration: [%s] %s') %(registration.id, registration.name) + body = registration.event_id.mail_registr + if (registration.event_id.state in ['confirm', 'running']) and registration.event_id.mail_auto_confirm: + subject = _('Auto Confirmation: [%s] %s') %(registration.id, registration.name) + body = registration.event_id.mail_confirm if subject or body: - mail_message.schedule_with_attach(cr, uid, src, email_to, subject, body, model='event.registration', email_cc=email_cc, res_id=regestration.id) + mail_message.schedule_with_attach(cr, uid, src, email_to, subject, body, model='event.registration', email_cc=email_cc, res_id=registration.id) return True diff --git a/addons/event/wizard/__init__.py b/addons/event/wizard/__init__.py index 2c04a0f5fcd..fbc44f417f4 100644 --- a/addons/event/wizard/__init__.py +++ b/addons/event/wizard/__init__.py @@ -23,5 +23,4 @@ import event_make_invoice import event_confirm_registration import event_confirm import partner_event_registration -import email_compose_message # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/event/wizard/email_compose_message.py b/addons/event/wizard/email_compose_message.py deleted file mode 100644 index fc664a62f6f..00000000000 --- a/addons/event/wizard/email_compose_message.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2010-Today OpenERP SA () -# -# 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 -# -############################################################################## - -from osv import osv -from osv import fields -import tools - -class email_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(email_compose_message, self).get_value(cr, uid, model, resource_id, context=context) - if model == 'event.registration' and resource_id: - model_obj = self.pool.get(model) - data = model_obj.browse(cr, uid , resource_id, context) - result.update({ - 'subject' : data.event_id.name or False, - 'email_to' : data.email_from or False, - 'email_from' : data.user_id and data.user_id.address_id and data.user_id.address_id.email or False, - 'body_text' : '\n' + (tools.ustr(data.user_id.signature or '')), - 'email_cc' : tools.ustr(data.email_cc or ''), - 'model': model, - 'res_id': resource_id, - }) - return result - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: