[IMP] event: spellcheck, simplify mail compose wizard

bzr revid: odo@openerp.com-20110907172500-0lxme3pvcwzipeh0
This commit is contained in:
Olivier Dony 2011-09-07 19:25:00 +02:00
parent 98165a1522
commit 1487e07364
4 changed files with 19 additions and 72 deletions

View File

@ -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
* ...

View File

@ -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

View File

@ -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:

View File

@ -1,54 +0,0 @@
# -*- 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
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: