summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2010-07-02 18:31:01 +0200
committerOlivier Dony <odo@openerp.com>2010-07-02 18:31:01 +0200
commit8a7fe0ed1be567c5d0370873b0358abd8d61bcff (patch)
tree25bf89d0d5c8e23d56493c99241f74f4914bf1e7
parent2242376b8bb295f282ac2d7e1f798705e9df01a7 (diff)
[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
-rw-r--r--addons/crm/crm.py2
-rw-r--r--addons/crm/crm_lead_view.xml11
-rw-r--r--addons/crm/crm_opportunity_view.xml10
-rw-r--r--addons/crm/wizard/crm_forward_to_partner.py2
-rw-r--r--addons/crm/wizard/crm_lead_to_opportunity.py2
-rw-r--r--addons/crm/wizard/crm_send_email.py24
-rw-r--r--addons/mail_gateway/mail_gateway.py72
-rw-r--r--addons/mail_gateway/mail_gateway_view.xml30
8 files changed, 80 insertions, 73 deletions
diff --git a/addons/crm/crm.py b/addons/crm/crm.py
index 882cb269d19..5bd0e01c113 100644
--- a/addons/crm/crm.py
+++ b/addons/crm/crm.py
@@ -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, \
diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml
index 60b682ae54a..c429810e31f 100644
--- a/addons/crm/crm_lead_view.xml
+++ b/addons/crm/crm_lead_view.xml
@@ -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" />
diff --git a/addons/crm/crm_opportunity_view.xml b/addons/crm/crm_opportunity_view.xml
index 3a04be60a93..ea959f7bd1a 100644
--- a/addons/crm/crm_opportunity_view.xml
+++ b/addons/crm/crm_opportunity_view.xml
@@ -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">
diff --git a/addons/crm/wizard/crm_forward_to_partner.py b/addons/crm/wizard/crm_forward_to_partner.py
index 60dbace1e53..fb607eefdbc 100644
--- a/addons/crm/wizard/crm_forward_to_partner.py
+++ b/addons/crm/wizard/crm_forward_to_partner.py
@@ -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.'))
diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py
index 5560ec507bf..a77f553b173 100644
--- a/addons/crm/wizard/crm_lead_to_opportunity.py
+++ b/addons/crm/wizard/crm_lead_to_opportunity.py
@@ -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)
diff --git a/addons/crm/wizard/crm_send_email.py b/addons/crm/wizard/crm_send_email.py
index bcb52e9bd48..6466b2877a3 100644
--- a/addons/crm/wizard/crm_send_email.py
+++ b/addons/crm/wizard/crm_send_email.py
@@ -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()
diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py
index e893e3648d5..2c778241daf 100644
--- a/addons/mail_gateway/mail_gateway.py
+++ b/addons/mail_gateway/mail_gateway.py
@@ -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(),
diff --git a/addons/mail_gateway/mail_gateway_view.xml b/addons/mail_gateway/mail_gateway_view.xml
index 05dd1e32e34..415dc192e50 100644
--- a/addons/mail_gateway/mail_gateway_view.xml
+++ b/addons/mail_gateway/mail_gateway_view.xml
@@ -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">