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/event | |
| 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/event')
| -rw-r--r-- | addons/event/__openerp__.py | 4 | ||||
| -rw-r--r-- | addons/event/event.py | 57 | ||||
| -rw-r--r-- | addons/event/event_view.xml | 39 |
3 files changed, 48 insertions, 52 deletions
diff --git a/addons/event/__openerp__.py b/addons/event/__openerp__.py index 680cf1e6572..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 * ... @@ -39,7 +39,7 @@ Note that: Association / Configuration / Types of Events """, 'author': 'OpenERP SA', - 'depends': ['crm', 'base_contact', 'account', 'marketing'], + 'depends': ['crm', 'base_contact', 'account', 'marketing', 'mail'], 'init_xml': [], 'update_xml': [ 'security/event_security.xml', diff --git a/addons/event/event.py b/addons/event/event.py index 0fc28c7c193..ba802ef1ffa 100644 --- a/addons/event/event.py +++ b/addons/event/event.py @@ -24,8 +24,11 @@ import time from crm import crm from osv import fields, osv from tools.translate import _ -import tools 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 """ @@ -280,7 +283,7 @@ class event_registration(osv.osv): """Event Registration""" _name= 'event.registration' _description = __doc__ - _inherit = 'mailgate.thread' + _inherit = 'mail.thread' def _amount_line(self, cr, uid, ids, field_name, arg, context=None): cur_obj = self.pool.get('res.currency') @@ -313,8 +316,8 @@ class event_registration(osv.osv): 'create_date': fields.datetime('Creation Date', readonly=True), 'write_date': fields.datetime('Write Date', readonly=True), 'description': fields.text('Description', states={'done': [('readonly', True)]}), - 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]), - 'log_ids': fields.one2many('mailgate.message', 'res_id', 'Logs', domain=[('history', '=', False),('model','=',_name)]), + 'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]), + 'log_ids': fields.one2many('mail.message', 'res_id', 'Logs', domain=[('email_from', '=', False),('model','=',_name)]), 'date_deadline': fields.related('event_id','date_end', type='datetime', string="End Date", readonly=True), 'date': fields.related('event_id', 'date_begin', type='datetime', string="Start Date", readonly=True), 'user_id': fields.many2one('res.users', 'Responsible', states={'done': [('readonly', True)]}), @@ -354,7 +357,7 @@ class event_registration(osv.osv): }) inv_id = inv_pool.create(cr, uid, val_invoice['value'], context=context) inv_pool.button_compute(cr, uid, [inv_id]) - self.history(cr, uid, [reg], _('Invoiced')) + self.message_append(cr, uid, [reg], _('Invoiced')) return inv_id def copy(self, cr, uid, id, default=None, context=None): @@ -429,7 +432,7 @@ class event_registration(osv.osv): """ res = self.write(cr, uid, ids, {'state': 'open'}, context=context) self.mail_user(cr, uid, ids) - self.history(cr, uid, ids, _('Open')) + self.message_append(cr, uid, ids, _('Open')) return res def do_close(self, cr, uid, ids, context=None): @@ -443,7 +446,7 @@ class event_registration(osv.osv): if invoice_id: values['invoice_id'] = invoice_id res = self.write(cr, uid, ids, values) - self.history(cr, uid, ids, msg) + self.message_append(cr, uid, ids, msg) return res def check_confirm(self, cr, uid, ids, context=None): @@ -514,42 +517,38 @@ class event_registration(osv.osv): """This Function Cancel Event Registration. """ registrations = self.browse(cr, uid, ids) - self.history(cr, uid, registrations, _('Cancel')) + self.message_append(cr, uid, registrations, _('Cancel')) return self.write(cr, uid, ids, {'state': 'cancel'}) def mail_user(self, cr, uid, ids, confirm=False, context=None): """ Send email to user """ - - for regestration in self.browse(cr, uid, ids, context=context): - src = regestration.event_id.reply_to or False + mail_message = self.pool.get('mail.message') + 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: - tools.email_send(src, email_to, subject, body, email_cc=email_cc, openobject_id=regestration.id) - self.history(cr, uid, [regestration], subject, history = True, \ - email=email_to, details=body, \ - subject=subject, email_from=src, \ - email_cc=', '.join(email_cc)) + 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/event_view.xml b/addons/event/event_view.xml index 6eafd851559..41c328d8908 100644 --- a/addons/event/event_view.xml +++ b/addons/event/event_view.xml @@ -391,12 +391,12 @@ <field name="message_ids" colspan="4" nolabel="1" mode="tree,form"> <tree string="History"> <field name="display_text" string="History Information"/> - <field name="history" invisible="1"/> - <button - string="Reply" attrs="{'invisible': [('history', '!=', True)]}" - name="%(crm.action_crm_send_mail)d" - context="{'mail':'reply', 'model': 'event.registration', 'include_original' : True}" - icon="terp-mail-replied" type="action" /> + <field name="email_from" invisible="1"/> + <button + string="Reply" attrs="{'invisible': [('email_from', '=', False)]}" + name="%(mail.action_email_compose_message_wizard)d" + context="{'mail.compose.message.mode':'reply', 'message_id':active_id}" + icon="terp-mail-replied" type="action" /> </tree> <form string="History"> <group col="4" colspan="4"> @@ -404,20 +404,18 @@ <field name="date"/> <field name="email_to" widget="char" size="512"/> <field name="email_cc" widget="char" size="512"/> - <field name="name" colspan="4" widget="char" size="512"/> - <field name="history" invisible="1"/> + <field name="subject" colspan="4" widget="char" size="512"/> </group> <notebook colspan="4"> <page string="Details"> - <group attrs="{'invisible': [('history', '!=', True)]}"> - <field name="description" colspan="4" nolabel="1" height="250"/> - <button colspan="4" - string="Reply" - name="%(crm.action_crm_send_mail)d" - context="{'mail':'reply', 'model': 'event.registration', 'include_original' : True}" - icon="terp-mail-replied" type="action" /> + <group attrs="{'invisible': [('email_from', '=', False)]}"> + <field name="body_text" colspan="4" nolabel="1" height="250"/> + <button colspan="4" string="Reply" + name="%(mail.action_email_compose_message_wizard)d" + context="{'mail.compose.message.mode':'reply', 'message_id':active_id}" + icon="terp-mail-replied" type="action"/> </group> - <group attrs="{'invisible': [('history', '=', True)]}"> + <group attrs="{'invisible': [('email_from', '!=', False)]}"> <field name="display_text" colspan="4" nolabel="1" height="250"/> </group> </page> @@ -427,14 +425,13 @@ </notebook> </form> </field> - <button string="Add Internal Note" + <button string="Add Internal Note" name="%(crm.action_crm_add_note)d" context="{'model': 'crm.lead' }" icon="terp-document-new" type="action" /> - <button string="Send New Email" - name="%(crm.action_crm_send_mail)d" - context="{'mail':'new', 'model': 'event.registration'}" - icon="terp-mail-message-new" type="action" /> + <button string="Send New Email" + name="%(mail.action_email_compose_message_wizard)d" + icon="terp-mail-message-new" type="action"/> </page> </notebook> </form> |
