[IMP] mail.thread: renaming methods to avoid collisions with objects that use the mixin
bzr revid: odo@openerp.com-20110823175809-hw81fkptg90702vh
This commit is contained in:
parent
4fcb67bef1
commit
b0bed63351
|
@ -501,7 +501,7 @@ class crm_case(crm_base):
|
|||
def format_mail(self, obj, body):
|
||||
return self.pool.get('base.action.rule').format_mail(obj, body)
|
||||
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
def message_thread_followers(self, cr, uid, ids, context=None):
|
||||
res = {}
|
||||
for case in self.browse(cr, uid, ids, context=context):
|
||||
l=[]
|
||||
|
|
|
@ -162,7 +162,7 @@ class email_server(osv.osv):
|
|||
result, data = imap_server.search(None, '(UNSEEN)')
|
||||
for num in data[0].split():
|
||||
result, data = imap_server.fetch(num, '(RFC822)')
|
||||
res_id = thread_pool.process_email(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context)
|
||||
res_id = thread_pool.message_process(cr, user, server.object_id.model, data[0][1], attach=server.attach, context=context)
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
|
||||
|
@ -184,7 +184,7 @@ class email_server(osv.osv):
|
|||
for num in range(1, numMsgs + 1):
|
||||
(header, msges, octets) = pop_server.retr(num)
|
||||
msg = '\n'.join(msges)
|
||||
res_id = thread_pool.process_email(cr, user, server.object_id.model, msg, attach=server.attach, context=context)
|
||||
res_id = thread_pool.message_process(cr, user, server.object_id.model, msg, attach=server.attach, context=context)
|
||||
if res_id and server.action_id:
|
||||
action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]})
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
# Copyright (C) 2010-Today OpenERP S.A. (<http://www.openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -28,15 +28,28 @@
|
|||
A generic email subsystem with message storage and queuing
|
||||
==========================================================
|
||||
|
||||
* Uses the global Outgoing Mail Servers for sending mail
|
||||
This email subsystem is not intended to be used as as standalone
|
||||
application, but to provide a unified email abstraction that all
|
||||
other applications can use.
|
||||
|
||||
The main features are:
|
||||
|
||||
* Relies on the global Outgoing Mail Servers configured in the
|
||||
Administration menu for delivering outgoing mail
|
||||
* Provides an API for sending messages and archiving them,
|
||||
grouped by conversation
|
||||
* Any OpenERP document can act as a conversation topic, provided
|
||||
it includes the necessary support for handling incoming emails
|
||||
(see the ``mail.thread`` class for more details).
|
||||
* Includes queuing mechanism with automated configurable
|
||||
scheduler-based processing
|
||||
* Includes a generic mail composition wizard, including
|
||||
a simple mechanism for mass-mailing with the use of
|
||||
basic templates - see ``email_template`` module for
|
||||
more features
|
||||
* Includes a generic email composition assistant, that can turn
|
||||
into a mass-mailing assistant, and is capable of interpreting
|
||||
simple *placeholder expressions* that will be replaced with
|
||||
dynamic data when each email is actually sent.
|
||||
This generic assistant is easily extensible to provide advanced
|
||||
features (see ``email_template`` for example, which adds email
|
||||
templating features to this assistant)
|
||||
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
|
@ -44,7 +57,7 @@ A generic email subsystem with message storage and queuing
|
|||
'depends': ['base', 'base_tools'],
|
||||
'data': [
|
||||
"wizard/mail_compose_message_view.xml",
|
||||
"mail_view.xml",
|
||||
"mail_message_view.xml",
|
||||
"mail_thread_view.xml",
|
||||
"res_partner_view.xml",
|
||||
'security/ir.model.access.csv',
|
||||
|
|
|
@ -78,14 +78,16 @@ class mail_message_common(osv.osv_memory):
|
|||
'email_cc': fields.char('Cc', size=256, help='Carbon copy message recipients'),
|
||||
'email_bcc': fields.char('Bcc', size=256, help='Blind carbon copy message recipients'),
|
||||
'reply_to':fields.char('Reply-To', size=256, help='Preferred response address for the message'),
|
||||
'headers': fields.text('Message headers', help="Full message headers, e.g. SMTP session headers", readonly=1),
|
||||
'headers': fields.text('Message headers', readonly=1,
|
||||
help="Full message headers, e.g. SMTP session headers "
|
||||
"(usually available on inbound messages only)"),
|
||||
'message_id': fields.char('Message-Id', size=256, help='Message unique identifier', select=1, readonly=1),
|
||||
'references': fields.text('References', help='Message references, such as identifiers of previous messages', readonly=1),
|
||||
'subtype': fields.char('Message type', size=32, help="Type of message, usually 'html' or 'plain', used to "
|
||||
"select plaintext or rich text contents accordingly", readonly=1),
|
||||
'body_text': fields.text('Text contents', help="Plain-text version of the message"),
|
||||
'body_html': fields.text('Rich-text contents', help="Rich-text/HTML version of the message"),
|
||||
'original': fields.text('Original', help="Original version of the message, before being imported by the system", readonly=1),
|
||||
'original': fields.text('Original', help="Original version of the message, as it was sent on the network", readonly=1),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
|
@ -151,8 +153,8 @@ class mail_message(osv.osv):
|
|||
msg_txt = ''
|
||||
if message.email_from:
|
||||
msg_txt += _('%s wrote on %s: \n Subject: %s \n\t') % (message.email_from or '/', format_date_tz(message.date, tz), message.subject)
|
||||
if message.body:
|
||||
msg_txt += truncate_text(message.body)
|
||||
if message.body_text:
|
||||
msg_txt += truncate_text(message.body_text)
|
||||
else:
|
||||
msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||
msg_txt += message.subject
|
||||
|
@ -175,11 +177,22 @@ class mail_message(osv.osv):
|
|||
'auto_delete': fields.boolean('Auto Delete', help="Permanently delete this email after sending it"),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'outgoing',
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""SELECT indexname FROM pg_indexes WHERE indexname = 'mail_message_model_res_id_idx'""")
|
||||
if not cr.fetchone():
|
||||
cr.execute("""CREATE INDEX mail_message_model_res_id_idx ON mail_message (model, res_id)""")
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
"""Overridden to avoid duplicating fields that are unique to each email"""
|
||||
if default is None:
|
||||
default = {}
|
||||
default.update(message_id=False,original=False,headers=False)
|
||||
return super(mail_message,self).copy(cr, uid, id, default=default, context=context)
|
||||
|
||||
def schedule_with_attach(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None,
|
||||
email_bcc=None, reply_to=False, attachments=None, message_id=False, references=False,
|
||||
res_id=False, subtype='plain', headers=None, mail_server_id=False, auto_delete=False,
|
||||
|
@ -474,7 +487,8 @@ class mail_message(osv.osv):
|
|||
mail_server_id=message.mail_server_id.id,
|
||||
context=context)
|
||||
if res:
|
||||
message.write({'state':'sent', 'message_id': res})
|
||||
message.write({'state':'sent', 'message_id': res,
|
||||
'original': msg.as_string(message.email_from)})
|
||||
else:
|
||||
message.write({'state':'exception'})
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Email message">
|
||||
<group colspan="4" col="8">
|
||||
<field name="subject"/>
|
||||
<group colspan="4" col="6">
|
||||
<field name="subject" colspan="4"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id" string="User"/>
|
||||
<field name="partner_id" readonly="1" />
|
||||
<field name="partner_id" readonly="1" attrs="{'invisible':[('partner_id', '=', False)]}"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
|
@ -22,17 +22,17 @@
|
|||
<separator string="Recipients" colspan="4"/>
|
||||
<field name="email_from"/>
|
||||
<field name="email_to"/>
|
||||
<field name="email_cc"/>
|
||||
<field name="email_bcc" groups="base.group_extended"/>
|
||||
<field name="reply_to"/>
|
||||
<field name="email_cc" attrs="{'invisible':[('email_cc', '=', False)]}"/>
|
||||
<field name="email_bcc" groups="base.group_extended" attrs="{'invisible':[('email_bcc', '=', False)]}"/>
|
||||
<field name="reply_to" attrs="{'invisible':[('reply_to', '=', False)]}"/>
|
||||
</group>
|
||||
<group col="4" colspan="2">
|
||||
<separator string="Message Details" colspan="4"/>
|
||||
<field name="model"/>
|
||||
<button name="open_document" string="Open" type="object" icon="gtk-jump-to" colspan="2"/>
|
||||
<field name="res_id" groups="base.group_extended"/>
|
||||
<field name="message_id" groups="base.group_extended" colspan="4"/>
|
||||
<field name="references" colspan="4" widget="char" size="4096" groups="base.group_extended"/>
|
||||
<field name="message_id" groups="base.group_extended" colspan="4" attrs="{'invisible':[('message_id', '=', False)]}"/>
|
||||
<field name="references" colspan="4" widget="char" size="512" groups="base.group_extended" attrs="{'invisible':[('references', '=', False)]}"/>
|
||||
</group>
|
||||
|
||||
<notebook colspan="4">
|
||||
|
@ -49,7 +49,7 @@
|
|||
<field name="state" colspan="2"/>
|
||||
<group col="4" colspan="2">
|
||||
<button name="%(action_email_compose_message_wizard)d" string="Reply" type="action" icon="terp-mail-replied"
|
||||
context="{'mail':'reply', 'message_id':active_id}" states='received,outgoing,sent,exception,cancel'/>
|
||||
context="{'mail':'reply', 'message_id':active_id}" states='received,sent,exception,cancel'/>
|
||||
<button name="send" string="Send Now" type="object" icon="gtk-media-play" states='outgoing'/>
|
||||
<button name="mark_outgoing" string="Retry" type="object" icon="gtk-redo" states='exception,cancel'/>
|
||||
<button name="cancel" string="Cancel" type="object" icon="terp-gtk-stop" states='outgoing'/>
|
||||
|
@ -60,12 +60,13 @@
|
|||
<separator string="Attachments" colspan="4"/>
|
||||
<field name="attachment_ids" nolabel="1" colspan="4"/>
|
||||
</page>
|
||||
<page string="Advanced">
|
||||
<page string="Advanced" groups="base.group_extended">
|
||||
<group col="2" colspan="4">
|
||||
<field name="mail_server_id"/>
|
||||
<field name="subtype" groups="base.group_extended"/>
|
||||
<field name="mail_server_id" attrs="{'invisible':[('mail_server_id', '=', False)]}"/>
|
||||
<field name="subtype" attrs="{'invisible':[('subtype', '=', False)]}"/>
|
||||
<field name="auto_delete"/>
|
||||
<field name="headers" colspan="4" groups="base.group_extended" height="350"/>
|
||||
<field name="headers" colspan="4" attrs="{'invisible':[('headers', '=', False)]}"/>
|
||||
<field name="original" colspan="4" height="350" attrs="{'invisible':[('original', '=', False)]}"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
import time
|
||||
import tools
|
||||
import binascii
|
||||
import base64
|
||||
import email
|
||||
from email.utils import parsedate
|
||||
|
||||
|
@ -36,6 +36,8 @@ _logger = logging.getLogger('mail')
|
|||
class mail_thread(osv.osv):
|
||||
'''Mixin model, meant to be inherited by any model that needs to
|
||||
act as a discussion topic on which messages can be attached.
|
||||
Public methods are prefixed in order to avoid name collisions
|
||||
with existing methods of the models that will use this mixin.
|
||||
|
||||
mail.thread adds a one2many of mail.messages, acting as thread
|
||||
history, and a few methods that may be overridden to implement
|
||||
|
@ -48,7 +50,7 @@ class mail_thread(osv.osv):
|
|||
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', readonly=True),
|
||||
}
|
||||
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
def message_thread_followers(self, cr, uid, ids, context=None):
|
||||
"""Returns a list of email addresses of the people following
|
||||
this thread, including the sender of each mail, and the
|
||||
people who were in CC of the messages, if any.
|
||||
|
@ -78,7 +80,7 @@ class mail_thread(osv.osv):
|
|||
return super(mail_thread, self).copy(cr, uid, id, default, context=context)
|
||||
|
||||
def message_new(self, cr, uid, msg_dict, custom_values=None, context=None):
|
||||
"""Called by ``process_email`` when a new message is received
|
||||
"""Called by ``message_process`` when a new message is received
|
||||
without referencing an existing thread. The default
|
||||
behavior is to create a new record of the corresponding
|
||||
model, then call ``append_mail()`` to attach a new
|
||||
|
@ -86,7 +88,7 @@ class mail_thread(osv.osv):
|
|||
Additional behavior may be implemented by overriding this method.
|
||||
|
||||
:param dict msg_dict: a map containing the email details and
|
||||
attachments. See ``process_email`` and
|
||||
attachments. See ``message_process`` and
|
||||
``mail.message.parse()`` for details.
|
||||
:param dict custom_values: optional dictionary of additional
|
||||
field values to pass to create()
|
||||
|
@ -115,7 +117,7 @@ class mail_thread(osv.osv):
|
|||
return res_id
|
||||
|
||||
def message_update(self, cr, uid, ids, msg_dict, vals={}, default_act=None, context=None):
|
||||
"""Called by ``process_email`` when a new message is received
|
||||
"""Called by ``message_process`` when a new message is received
|
||||
for an existing thread. The default behavior is to create a
|
||||
new mail.message in the given thread by calling
|
||||
``append_mail()``.
|
||||
|
@ -123,7 +125,7 @@ class mail_thread(osv.osv):
|
|||
method.
|
||||
|
||||
:param dict msg_dict: a map containing the email details and
|
||||
attachments. See ``process_email`` and
|
||||
attachments. See ``message_process`` and
|
||||
``mail.message.parse()`` for details.
|
||||
:param dict context: if a ``thread_model`` value is present
|
||||
in the context, its value will be used
|
||||
|
@ -140,7 +142,7 @@ class mail_thread(osv.osv):
|
|||
message.
|
||||
|
||||
:param dict msg_dict: a map containing the email details and
|
||||
attachments. See ``process_email`` and
|
||||
attachments. See ``message_process`` and
|
||||
``mail.message.parse()`` for details.
|
||||
:param dict context: if a ``thread_model`` value is present
|
||||
in the context, its value will be used
|
||||
|
@ -224,7 +226,7 @@ class mail_thread(osv.osv):
|
|||
fcontent = fcontent.encode('utf-8')
|
||||
data_attach = {
|
||||
'name': fname,
|
||||
'datas': binascii.b2a_base64(str(fcontent)),
|
||||
'datas': base64.b64encode(str(fcontent)),
|
||||
'datas_fname': fname,
|
||||
'description': _('Mail attachment'),
|
||||
'res_model': thread._name,
|
||||
|
@ -277,12 +279,12 @@ class mail_thread(osv.osv):
|
|||
mail_message.create(cr, uid, data, context=context)
|
||||
return True
|
||||
|
||||
def process_email(self, cr, uid, model, message, custom_values=None, context=None):
|
||||
def message_process(self, cr, uid, model, message, custom_values=None, context=None):
|
||||
"""Process an incoming RFC2822 email message related to the
|
||||
given thread model, relying on ``mail.message.parse()``
|
||||
for the parsing operation, and then calling ``message_new``
|
||||
(if the thread record did not exist) or ``message_update``
|
||||
(if it did), then calling ``email_forward()`` to automatically
|
||||
(if it did), then calling ``message_forward()`` to automatically
|
||||
notify other people that should receive this email.
|
||||
|
||||
:param string model: the thread model for which a new message
|
||||
|
@ -346,10 +348,13 @@ class mail_thread(osv.osv):
|
|||
if not res_id:
|
||||
res_id = create_record(msg)
|
||||
#To forward the email to other followers
|
||||
self.email_forward(cr, uid, model, [res_id], msg_txt, context=context)
|
||||
self.message_forward(cr, uid, model, [res_id], msg_txt, context=context)
|
||||
return res_id
|
||||
|
||||
def email_forward(self, cr, uid, model, thread_ids, msg, email_error=False, context=None):
|
||||
# for backwards-compatibility with old scripts
|
||||
process_email = message_process
|
||||
|
||||
def message_forward(self, cr, uid, model, thread_ids, msg, email_error=False, context=None):
|
||||
"""Sends an email to all people following the given threads.
|
||||
The emails are forwarded immediately, not queued for sending,
|
||||
and not archived.
|
||||
|
@ -365,10 +370,11 @@ class mail_thread(osv.osv):
|
|||
smtp_server_obj = self.pool.get('ir.mail_server')
|
||||
mail_message = self.pool.get('mail.message')
|
||||
for res in model_pool.browse(cr, uid, thread_ids, context=context):
|
||||
if hasattr(model_pool, 'thread_followers'):
|
||||
self.thread_followers = model_pool.thread_followers
|
||||
thread_followers = self.thread_followers(cr, uid, [res.id])[res.id]
|
||||
message_followers_emails = mail_message.to_email(','.join(filter(None, thread_followers)))
|
||||
if hasattr(model_pool, 'message_thread_followers'):
|
||||
followers = model_pool.message_thread_followers(cr, uid, [res.id])[res.id]
|
||||
else:
|
||||
followers = self.message_thread_followers(cr, uid, [res.id])[res.id]
|
||||
message_followers_emails = mail_message.to_email(','.join(filter(None, followers)))
|
||||
message_recipients = mail_message.to_email(','.join(filter(None,
|
||||
[decode(msg['from']),
|
||||
decode(msg['to']),
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="view_mailgate_thread_form">
|
||||
<field name="name">mail.thread.form</field>
|
||||
<field name="model">mail.thread</field>
|
||||
|
@ -17,7 +16,6 @@
|
|||
<field name="subject" widget="char"/>
|
||||
<field name="date"/>
|
||||
<field name="user_id"/>
|
||||
<field name="message_id"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Email Details">
|
||||
<group col="4" colspan="4">
|
||||
|
@ -29,7 +27,6 @@
|
|||
</group>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<separator string="Attachments" colspan="4"/>
|
||||
<field name="attachment_ids" nolabel="1" colspan="4" />
|
||||
</page>
|
||||
</notebook>
|
||||
|
|
|
@ -110,7 +110,7 @@ class EmailParser(object):
|
|||
# pass message as bytes because we don't know its encoding until we parse its headers
|
||||
# and hence can't convert it to utf-8 for transport
|
||||
res_id = self.rpc('mail.thread',
|
||||
'process_email',
|
||||
'message_process',
|
||||
self.model,
|
||||
xmlrpclib.Binary(message),
|
||||
custom_values)
|
||||
|
|
|
@ -126,42 +126,46 @@ class mail_compose_message(osv.osv_memory):
|
|||
# we use the plain text version of the original mail, by default,
|
||||
# as it is easier to quote than the HTML version.
|
||||
# XXX TODO: make it possible to switch to HTML on the fly
|
||||
description = message_data.body_text or ''
|
||||
body = message_data.body_text or ''
|
||||
if context.get('mail') == 'reply':
|
||||
header = _('-------- Original Message --------')
|
||||
sender = _('From: %s') % tools.ustr(message_data.email_from or '')
|
||||
email_to = _('To: %s') % tools.ustr(message_data.email_to or '')
|
||||
sentdate = _('Date: %s') % message_data.date
|
||||
desc = '\n > \t %s' % tools.ustr(description.replace('\n', "\n > \t") or '')
|
||||
description = '\n'.join([header, sender, email_to, sentdate, desc])
|
||||
sentdate = _('Date: %s') % message_data.date if message_data.date else ''
|
||||
quoted_body = '> \n> %s' % tools.ustr(body.replace('\n', "\n> ") or '')
|
||||
body = '\n'.join(filter(None, ["\n", header, sender, email_to, sentdate,
|
||||
quoted_body]))
|
||||
re_prefix = _("Re:")
|
||||
if not (subject.startswith('Re:') or subject.startswith(re_prefix)):
|
||||
subject = "%s %s" % (re_prefix, subject)
|
||||
current_user = self.pool.get('res.users').browse(cr, uid, uid, context)
|
||||
result.update({
|
||||
'subtype' : 'plain', # default to the text version due to quoting
|
||||
'body_text' : description,
|
||||
'body_text' : body,
|
||||
'subject' : subject,
|
||||
'message_id' : message_data.message_id or False,
|
||||
'attachment_ids' : [],
|
||||
'res_id' : message_data.res_id or False,
|
||||
'email_from' : message_data.email_to or False,
|
||||
'email_to' : message_data.email_from or False,
|
||||
'email_cc' : message_data.email_cc or False,
|
||||
'email_bcc' : message_data.email_bcc or False,
|
||||
'reply_to' : message_data.reply_to or False,
|
||||
'model' : message_data.model or False,
|
||||
'user_id' : message_data.user_id and message_data.user_id.id or False,
|
||||
'res_id' : message_data.res_id or False,
|
||||
'email_from' : current_user.user_email or message_data.email_to or False,
|
||||
'email_to' : message_data.reply_to or message_data.email_from or False,
|
||||
'email_cc' : message_data.email_cc or False,
|
||||
'user_id' : uid,
|
||||
|
||||
# pass msg-id and references of mail we're replying to, to construct the
|
||||
# new ones later when sending
|
||||
'message_id' : message_data.message_id or False,
|
||||
'references' : message_data.references and tools.ustr(message_data.references) or False,
|
||||
'headers' : message_data.headers or False,
|
||||
})
|
||||
return result
|
||||
|
||||
def send_mail(self, cr, uid, ids, context=None):
|
||||
'''Process the wizard contents and proceed with sending the corresponding
|
||||
email(s), rendering any template patterns on the fly if needed.
|
||||
The resulting email(s) are scheduled for being sent the next time the
|
||||
mail.message scheduler runs, or the next time
|
||||
If the wizard is in mass-mail mode (context has a ``mass_mail`` key),
|
||||
the resulting email(s) are scheduled for being sent the next time
|
||||
the mail.message scheduler runs, or the next time
|
||||
``mail.message.process_email_queue`` is called.
|
||||
Otherwise the new message is sent immediately.
|
||||
|
||||
:param dict context: several context values will modify the behavior
|
||||
of the wizard, cfr. the class description.
|
||||
|
@ -173,14 +177,15 @@ class mail_compose_message(osv.osv_memory):
|
|||
attachment = {}
|
||||
for attach in mail.attachment_ids:
|
||||
attachment[attach.datas_fname] = attach.datas
|
||||
references = False
|
||||
message_id = False
|
||||
references = None
|
||||
headers = {}
|
||||
|
||||
body = mail.body_html if mail.subtype == 'html' else mail.body_text
|
||||
|
||||
# Reply Email
|
||||
if context.get('mail') == 'reply' and mail.message_id:
|
||||
references = mail.references and mail.references + "," + mail.message_id or mail.message_id
|
||||
else:
|
||||
message_id = mail.message_id
|
||||
if context.get('mail') == 'reply' and mail.message_id:
|
||||
references = (mail.references or '') + " " + mail.message_id
|
||||
headers['In-Reply-To'] = mail.message_id
|
||||
|
||||
if context.get('mass_mail'):
|
||||
# Mass mailing: must render the template patterns
|
||||
|
@ -194,25 +199,27 @@ class mail_compose_message(osv.osv_memory):
|
|||
|
||||
for active_id in active_ids:
|
||||
subject = self.render_template(cr, uid, mail.subject, active_model, active_id)
|
||||
|
||||
body = mail.body_html if mail.subtype == 'html' else mail.body_text
|
||||
body = self.render_template(cr, uid, body, active_model, active_id)
|
||||
rendered_body = self.render_template(cr, uid, body, active_model, active_id)
|
||||
email_from = self.render_template(cr, uid, mail.email_from, active_model, active_id)
|
||||
email_to = self.render_template(cr, uid, mail.email_to, active_model, active_id)
|
||||
email_cc = self.render_template(cr, uid, mail.email_cc, active_model, active_id)
|
||||
email_bcc = self.render_template(cr, uid, mail.email_bcc, active_model, active_id)
|
||||
reply_to = self.render_template(cr, uid, mail.reply_to, active_model, active_id)
|
||||
|
||||
mail_message.schedule_with_attach(cr, uid, email_from, to_email(email_to), subject, body,
|
||||
# in mass-mailing mode we only schedule the mail for sending, it will be
|
||||
# processed as soon as the mail scheduler runs.
|
||||
mail_message.schedule_with_attach(cr, uid, email_from, to_email(email_to), subject, rendered_body,
|
||||
model=mail.model, email_cc=to_email(email_cc), email_bcc=to_email(email_bcc), reply_to=reply_to,
|
||||
attachments=attachment, message_id=message_id, references=references, res_id=int(mail.res_id),
|
||||
subtype=mail.subtype, headers=mail.headers, auto_delete=mail.auto_delete, context=context)
|
||||
attachments=attachment, references=references, res_id=int(mail.res_id),
|
||||
subtype=mail.subtype, headers=headers, context=context)
|
||||
else:
|
||||
# normal mode - no mass-mailing
|
||||
mail_message.schedule_with_attach(cr, uid, mail.email_from, to_email(mail.email_to), mail.subject, mail.body,
|
||||
msg_id = mail_message.schedule_with_attach(cr, uid, mail.email_from, to_email(mail.email_to), mail.subject, body,
|
||||
model=mail.model, email_cc=to_email(mail.email_cc), email_bcc=to_email(mail.email_bcc), reply_to=mail.reply_to,
|
||||
attachments=attachment, message_id=message_id, references=references, res_id=int(mail.res_id),
|
||||
subtype=mail.subtype, headers=mail.headers, auto_delete=mail.auto_delete, context=context)
|
||||
attachments=attachment, references=references, res_id=int(mail.res_id),
|
||||
subtype=mail.subtype, headers=headers, context=context)
|
||||
# in normal mode, we send the email immediately, as the user expects us to (delay should be sufficiently small)
|
||||
mail_message.send(cr, uid, [msg_id], context)
|
||||
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="email_compose_message_wizard_form">
|
||||
<field name="name">mail.compose.message.form</field>
|
||||
<field name="model">mail.compose.message</field>
|
||||
|
@ -17,21 +16,20 @@
|
|||
<field name="email_bcc" colspan="4"/>
|
||||
<field name="reply_to" colspan="4"/>
|
||||
<field name="subject" colspan="4" widget="char" size="512"/>
|
||||
<field name="auto_delete" colspan="4" invisible="1"/>
|
||||
<field name="references" invisible="1"/>
|
||||
<field name="message_id" invisible="1"/>
|
||||
</group>
|
||||
<separator string="" colspan="4"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Body">
|
||||
<field name="body_text" colspan="4" nolabel="1"/>
|
||||
<field name="body_text" colspan="4" nolabel="1" height="300" width="300"/>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
<label string="Add here all attachments of the current document you want to include in the Email." colspan="4"/>
|
||||
<field name="attachment_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="4" colspan="4">
|
||||
<label string="" colspan="1"/>
|
||||
<button icon="gtk-close" special="cancel" string="Close"/>
|
||||
<button icon="gtk-close" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
|
@ -39,7 +37,7 @@
|
|||
</record>
|
||||
|
||||
<record id="action_email_compose_message_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Compose E-mail</field>
|
||||
<field name="name">Compose Email</field>
|
||||
<field name="res_model">mail.compose.message</field>
|
||||
<field name="src_model">mail.compose.message</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
@ -48,14 +46,14 @@
|
|||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<!-- Replace the default mass-mailing wizard in base with the composition wizard -->
|
||||
<act_window name="Mass Mailing"
|
||||
res_model="mail.compose.message"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="base.action_partner_mass_mail"
|
||||
context="{'mass_mail':True}"/>
|
||||
<!-- Replace the default mass-mailing wizard in base with the composition wizard -->
|
||||
<act_window name="Mass Mailing"
|
||||
res_model="mail.compose.message"
|
||||
src_model="res.partner"
|
||||
view_mode="form"
|
||||
target="new"
|
||||
key2="client_action_multi"
|
||||
id="base.action_partner_mass_mail"
|
||||
context="{'mass_mail':True}"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -484,7 +484,7 @@ class marketing_campaign_activity(osv.osv):
|
|||
return True
|
||||
|
||||
def _process_wi_email(self, cr, uid, activity, workitem, context=None):
|
||||
return self.pool.get('email.template').generate_mail(cr, uid,
|
||||
return self.pool.get('email.template').send_mail(cr, uid,
|
||||
activity.email_template_id.id,
|
||||
[workitem.res_id], context=context)
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ class XMLRpcConn(object):
|
|||
endCut = message_id.find(">")
|
||||
message_id = message_id[startCut:endCut+1]
|
||||
email.replace_header('Message-Id',message_id)
|
||||
id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.thread','process_email',section, str(email))
|
||||
id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.thread','message_process',section, str(email))
|
||||
if id > 0:
|
||||
flag = True
|
||||
return flag
|
||||
|
|
|
@ -83,7 +83,7 @@ class project_tasks(osv.osv):
|
|||
self.append_mail(cr, uid, [res_id], msg, context=context)
|
||||
return True
|
||||
|
||||
def thread_followers(self, cr, uid, ids, context=None):
|
||||
def message_thread_followers(self, cr, uid, ids, context=None):
|
||||
res = []
|
||||
if isinstance(ids, (str, int, long)):
|
||||
select = [ids]
|
||||
|
|
|
@ -111,7 +111,7 @@ class thunderbird_partner(osv.osv_memory):
|
|||
dictcreate = dict(vals)
|
||||
model = str(dictcreate.get('model'))
|
||||
message = dictcreate.get('message')
|
||||
return self.pool.get('mail.thread').process_email(cr, uid, model, message, attach=True, context=None)
|
||||
return self.pool.get('mail.thread').message_process(cr, uid, model, message, attach=True, context=None)
|
||||
|
||||
def search_message(self, cr, uid, message, context=None):
|
||||
#@param message: string of mail which is read from EML File
|
||||
|
|
Loading…
Reference in New Issue