[IMP] crm, mail_gateway:
- added display and tracking of CC for mail history, also changed long headers to fields.text (no arbitrary limit) - improved crm views - made _history() method of mailgate.thread public - some additional cleanup bzr revid: odo@openerp.com-20100702163101-tiapsrpnf4hli6il
This commit is contained in:
parent
2242376b8b
commit
8a7fe0ed1b
|
@ -214,7 +214,7 @@ class crm_case(object):
|
|||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, email_from=False, message_id=False, attach=[], context={}):
|
||||
mailgate_pool = self.pool.get('mailgate.thread')
|
||||
return mailgate_pool._history(cr, uid, cases, keyword, history=history,\
|
||||
return mailgate_pool.history(cr, uid, cases, keyword, history=history,\
|
||||
subject=subject, email=email, \
|
||||
details=details, email_from=email_from,\
|
||||
message_id=message_id, attach=attach, \
|
||||
|
|
|
@ -157,16 +157,17 @@
|
|||
</page>
|
||||
<page string="Emails" groups="base.group_extended">
|
||||
<group colspan="4">
|
||||
<field colspan="4" name="email_cc" string="CC"/>
|
||||
<field colspan="4" name="email_cc" string="CC" widget="char" size="512"/>
|
||||
</group>
|
||||
<!-- TODO-->
|
||||
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree">
|
||||
<form string="Communication history">
|
||||
<group col="6" colspan="4">
|
||||
<group col="4" colspan="4">
|
||||
<field name="email_from"/>
|
||||
<field name="email_to"/>
|
||||
<field name="date"/>
|
||||
<field name="name" colspan="6"/>
|
||||
<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"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
|
@ -177,7 +178,7 @@
|
|||
</page>
|
||||
</notebook>
|
||||
<button colspan="4"
|
||||
string="Reply to Last Email"
|
||||
string="Reply"
|
||||
name="%(crm.action_crm_send_mail)d"
|
||||
context="{'mail':'reply', 'model': 'crm.lead', 'include_original' : True}"
|
||||
icon="gtk-undo" type="action" />
|
||||
|
|
|
@ -116,14 +116,16 @@
|
|||
|
||||
<page string="Emails" groups="base.group_extended">
|
||||
<group colspan="4">
|
||||
<field colspan="4" name="email_cc" string="CC"/>
|
||||
<field colspan="4" name="email_cc" string="Cc" widget="char" size="512"/>
|
||||
</group>
|
||||
<field name="message_ids" colspan="4" nolabel="1" mode="form,tree" height="280">
|
||||
<form string="Communication history">
|
||||
<group col="6" colspan="4">
|
||||
<field name="date"/>
|
||||
<field name="email_to"/>
|
||||
<group col="4" colspan="4">
|
||||
<field name="email_from"/>
|
||||
<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"/>
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
|
|
|
@ -217,7 +217,7 @@ class crm_lead_forward_to_partner(osv.osv_memory):
|
|||
)
|
||||
|
||||
if result:
|
||||
case_pool._history(cr, uid, [case], _('Forward'), history=True, email=this.email_to, subject=this.subject, details=body, email_from=email_from, attach=attach)
|
||||
case_pool.history(cr, uid, [case], _('Forward'), history=True, email=this.email_to, subject=this.subject, details=body, email_from=email_from, attach=attach)
|
||||
else:
|
||||
raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.'))
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class crm_lead2opportunity(osv.osv_memory):
|
|||
'type': 'opportunity'
|
||||
}
|
||||
lead_obj.write(cr, uid, lead.id, vals, context=context)
|
||||
lead_obj._history(cr, uid, [lead], _('Opportunity'), details='Converted to Opportunity', context=context)
|
||||
lead_obj.history(cr, uid, [lead], _('Opportunity'), details='Converted to Opportunity', context=context)
|
||||
if lead.partner_id:
|
||||
msg_ids = [ x.id for x in lead.message_ids]
|
||||
self.pool.get('mailgate.message').write(cr, uid, msg_ids, {'partner_id': lead.partner_id.id}, context=context)
|
||||
|
|
|
@ -45,17 +45,17 @@ class crm_send_new_email_attachment(osv.osv_memory):
|
|||
|
||||
crm_send_new_email_attachment()
|
||||
|
||||
class crm_send_new_email(osv.osv_memory):
|
||||
class crm_send_new_email2(osv.osv_memory):
|
||||
""" Sends new email for the case"""
|
||||
_name = "crm.send.mail"
|
||||
_description = "Send new email"
|
||||
|
||||
_columns = {
|
||||
'email_to' : fields.char('To', size=64, required=True),
|
||||
'email_from' : fields.char('From', size=64, required=True),
|
||||
'email_cc' : fields.char('CC', size=128, help="Carbon Copy: list of recipients that will receive"\
|
||||
'email_to' : fields.char('To', size=512, required=True),
|
||||
'email_from' : fields.char('From', size=128, required=True),
|
||||
'email_cc' : fields.char('CC', size=512, help="Carbon Copy: list of recipients that will receive"\
|
||||
" a copy of this mail, and future communication related to this case"),
|
||||
'subject': fields.char('Subject', size=128, required=True),
|
||||
'subject': fields.char('Subject', size=512, required=True),
|
||||
'text': fields.text('Message', required=True),
|
||||
'state': fields.selection(crm.AVAILABLE_STATES, string='Set New State To', required=True),
|
||||
|
||||
|
@ -72,7 +72,6 @@ class crm_send_new_email(osv.osv_memory):
|
|||
"""
|
||||
|
||||
hist_obj = self.pool.get('mailgate.message')
|
||||
smtp_pool = self.pool.get('email.smtpclient')
|
||||
|
||||
if not context:
|
||||
context = {}
|
||||
|
@ -130,10 +129,11 @@ class crm_send_new_email(osv.osv_memory):
|
|||
if not flag:
|
||||
raise osv.except_osv(_('Error!'), _('Unable to send mail. Please check SMTP is configured properly.'))
|
||||
if flag:
|
||||
case_pool._history(cr, uid, [case], _('Send'), history=True, \
|
||||
case_pool.history(cr, uid, [case], _('Send'), history=True, \
|
||||
email=obj.email_to, details=body, \
|
||||
subject=obj.subject, email_from=email_from, \
|
||||
message_id=message_id, references=ref_id or message_id, attach=attach)
|
||||
email_cc=email_cc, message_id=message_id, \
|
||||
references=ref_id or message_id, attach=attach)
|
||||
if obj.state == 'unchanged':
|
||||
pass
|
||||
elif obj.state == 'done':
|
||||
|
@ -248,13 +248,7 @@ class crm_send_new_email(osv.osv_memory):
|
|||
|
||||
if not context.get('model'):
|
||||
raise osv.except_osv(_('Error'), _('Can not send mail!'))
|
||||
model = context.get('model')
|
||||
mod_obj = self.pool.get(model)
|
||||
if context.get('mail') == 'reply':
|
||||
return True
|
||||
if tools.config.get('email_from'):
|
||||
return True
|
||||
return True
|
||||
|
||||
crm_send_new_email()
|
||||
crm_send_new_email2()
|
||||
|
||||
|
|
|
@ -69,8 +69,9 @@ class mailgate_thread(osv.osv):
|
|||
def msg_send(self, cr, uid, id, *args, **argv):
|
||||
raise Exception, _('Method is not implemented')
|
||||
|
||||
def _history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \
|
||||
email_from=False, message_id=False, references=None, attach=None, context=None):
|
||||
def history(self, cr, uid, cases, keyword, history=False, subject=None, email=False, details=None, \
|
||||
email_from=False, message_id=False, references=None, attach=None, email_cc=None, \
|
||||
email_bcc=None, email_date=None, context=None):
|
||||
"""
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
|
@ -78,8 +79,12 @@ class mailgate_thread(osv.osv):
|
|||
@param cases: a browse record list
|
||||
@param keyword: Case action keyword e.g.: If case is closed "Close" keyword is used
|
||||
@param history: Value True/False, If True it makes entry in case History otherwise in Case Log
|
||||
@param email: Email address if any
|
||||
@param details: Details of case history if any
|
||||
@param email: Email-To / Recipient address
|
||||
@param email_from: Email From / Sender address if any
|
||||
@param email_cc: Comma-Separated list of Carbon Copy Emails To addresse if any
|
||||
@param email_bcc: Comma-Separated list of Blind Carbon Copy Emails To addresses if any
|
||||
@param email_date: Email Date string if different from now, in server Timezone
|
||||
@param details: Description, Ddtails of case history if any
|
||||
@param atach: Attachment sent in email
|
||||
@param context: A standard dictionary for contextual values"""
|
||||
if context is None:
|
||||
|
@ -97,35 +102,39 @@ class mailgate_thread(osv.osv):
|
|||
|
||||
for case in cases:
|
||||
data = {
|
||||
'name': keyword,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'message_id': message_id,
|
||||
'name': keyword,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'message_id': message_id,
|
||||
}
|
||||
attachments = []
|
||||
if history:
|
||||
for att in attach:
|
||||
attachments.append(att_obj.create(cr, uid, {'name': att[0], 'datas': base64.encodestring(att[1])}))
|
||||
|
||||
for param in (email, email_cc, email_bcc):
|
||||
if isinstance(param, list):
|
||||
param = ", ".join(param)
|
||||
|
||||
data = {
|
||||
'name': subject or 'History',
|
||||
'history': True,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'name': subject or 'History',
|
||||
'history': True,
|
||||
'user_id': uid,
|
||||
'model' : case._name,
|
||||
'res_id': case.id,
|
||||
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'description': details or (hasattr(case, 'description') and case.description or False),
|
||||
'email_to': email or \
|
||||
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
|
||||
case.user_id.address_id.email) or tools.config.get('email_from', False),
|
||||
'date': email_date or time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'description': details or (hasattr(case, 'description') and case.description or False),
|
||||
'email_to': email,
|
||||
'email_from': email_from or \
|
||||
(hasattr(case, 'user_id') and case.user_id and case.user_id.address_id and \
|
||||
case.user_id.address_id.email) or tools.config.get('email_from', False),
|
||||
'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False,
|
||||
'references': references,
|
||||
'message_id': message_id,
|
||||
case.user_id.address_id.email),
|
||||
'email_cc': email_cc,
|
||||
'email_bcc': email_bcc,
|
||||
'partner_id': hasattr(case, 'partner_id') and (case.partner_id and case.partner_id.id or False) or False,
|
||||
'references': references,
|
||||
'message_id': message_id,
|
||||
'attachment_ids': [(6, 0, attachments)]
|
||||
}
|
||||
obj.create(cr, uid, data, context=context)
|
||||
|
@ -140,7 +149,7 @@ class mailgate_message(osv.osv):
|
|||
_description = 'Mailgateway Message'
|
||||
_order = 'id desc'
|
||||
_columns = {
|
||||
'name':fields.char('Subject', size=128),
|
||||
'name':fields.text('Subject'),
|
||||
'model': fields.char('Object Name', size=128, select=1),
|
||||
'res_id': fields.integer('Resource ID', select=1),
|
||||
'ref_id': fields.char('Reference Id', size=256, readonly=True, help="Message Id in Email Server.", select=True),
|
||||
|
@ -148,12 +157,12 @@ class mailgate_message(osv.osv):
|
|||
'history': fields.boolean('Is History?'),
|
||||
'user_id': fields.many2one('res.users', 'User Responsible', readonly=True),
|
||||
'message': fields.text('Description'),
|
||||
'email_from': fields.char('Email From', size=84),
|
||||
'email_to': fields.char('Email To', size=84),
|
||||
'email_cc': fields.char('Email CC', size=84),
|
||||
'email_bcc': fields.char('Email BCC', size=84),
|
||||
'email_from': fields.char('From', size=128, help="Email From"),
|
||||
'email_to': fields.text('To', help="Email Recipients"),
|
||||
'email_cc': fields.text('Cc', help="Carbon Copy Email Recipients"),
|
||||
'email_bcc': fields.text('Bcc', help='Blind Carbon Copy Email Recipients'),
|
||||
'message_id': fields.char('Message Id', size=1024, readonly=True, help="Message Id on Email.", select=True),
|
||||
'references': fields.text('References', readonly=True, help="Referencess emails."),
|
||||
'references': fields.text('References', readonly=True, help="References emails."),
|
||||
'description': fields.text('Description'),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', required=False),
|
||||
'attachment_ids': fields.many2many('ir.attachment', 'message_attachment_rel', 'message_id', 'attachment_id', 'Attachments'),
|
||||
|
@ -421,12 +430,13 @@ class mailgate_tool(osv.osv_memory):
|
|||
|
||||
# Store messages
|
||||
context.update({'model' : model})
|
||||
if hasattr(model_pool, '_history'):
|
||||
model_pool._history(cr, uid, res_ids, _('receive'), history=True,
|
||||
if hasattr(model_pool, 'history'):
|
||||
model_pool.history(cr, uid, res_ids, _('receive'), history=True,
|
||||
subject = msg.get('subject'),
|
||||
email = msg.get('to'),
|
||||
details = msg.get('body'),
|
||||
email_from = msg.get('from'),
|
||||
email_cc = msg.get('cc'),
|
||||
message_id = msg.get('message-id'),
|
||||
references = msg.get('references', False),
|
||||
attach = attachments.items(),
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="mailgate message">
|
||||
<group colspan="4" col="6">
|
||||
<field name="name" string="Subject" required="1" select="1"/>
|
||||
<field name="name" string="Subject" required="1" select="1" widget="char" size="512"/>
|
||||
<field name="date" required="1" select="1"/>
|
||||
<field name="user_id" string="Responsible" select="1"/>
|
||||
<field name="partner_id" readonly="1" />
|
||||
|
@ -18,9 +18,9 @@
|
|||
<group col="2" colspan="2">
|
||||
<separator string="Email Details" colspan="4"/>
|
||||
<field name="email_from" />
|
||||
<field name="email_to" />
|
||||
<field name="email_cc" />
|
||||
<field name="email_bcc" groups="base.group_extended"/>
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="email_bcc" widget="char" size="512" groups="base.group_extended"/>
|
||||
</group>
|
||||
<group col="2" colspan="2">
|
||||
<separator string="Message Details" colspan="4"/>
|
||||
|
@ -86,7 +86,7 @@
|
|||
<field name="date" />
|
||||
</tree>
|
||||
<form string="Mailgate Logs">
|
||||
<field name="name" />
|
||||
<field name="name" widget="char" size="512"/>
|
||||
<field name="date" />
|
||||
<field name="user_id" />
|
||||
<field name="message_id" />
|
||||
|
@ -95,9 +95,9 @@
|
|||
<group col="4" colspan="4">
|
||||
<separator string="Email Details" colspan="4"/>
|
||||
<field name="email_from" />
|
||||
<field name="email_to" />
|
||||
<field name="email_cc" />
|
||||
<field name="email_bcc" />
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="email_bcc" widget="char" size="512"/>
|
||||
</group>
|
||||
<separator string="Description" colspan="4"/>
|
||||
<field name="description" nolabel="1" colspan="4" />
|
||||
|
@ -109,14 +109,14 @@
|
|||
</notebook>
|
||||
</form>
|
||||
</field>
|
||||
<separator string="Histories" colspan="4"/>
|
||||
<separator string="History" colspan="4"/>
|
||||
<field name="message_ids" nolabel="1" colspan="4" domain="[('history', '=', True)]">
|
||||
<tree string="Mailgateway Histories">
|
||||
<tree string="Mailgateway History">
|
||||
<field name="name" select="1" />
|
||||
<field name="date" />
|
||||
</tree>
|
||||
<form string="Mailgate Histories">
|
||||
<field name="name" />
|
||||
<form string="Mailgate History">
|
||||
<field name="name" widget="char" size="512"/>
|
||||
<field name="date" />
|
||||
<field name="user_id" />
|
||||
<field name="message_id" />
|
||||
|
@ -126,9 +126,9 @@
|
|||
<group col="4" colspan="4">
|
||||
<separator string="Email Details" colspan="4"/>
|
||||
<field name="email_from" />
|
||||
<field name="email_to" />
|
||||
<field name="email_cc" />
|
||||
<field name="email_bcc" />
|
||||
<field name="email_to" widget="char" size="512"/>
|
||||
<field name="email_cc" widget="char" size="512"/>
|
||||
<field name="email_bcc" widget="char" size="512"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Attachments">
|
||||
|
|
Loading…
Reference in New Issue