[REVIEW]: improvement in to the crm module

improvement in crm for email integration

bzr revid: mga@tinyerp.com-20100417210721-9munqmiyynacaia4
This commit is contained in:
Mantavya Gajjar 2010-04-18 02:37:21 +05:30
parent 64ea0e8b38
commit 5aa72a05f1
6 changed files with 78 additions and 43 deletions

View File

@ -44,21 +44,24 @@ The CRM module has a email gateway for the synchronisation interface
between mails and Open ERP.""",
'author': 'Tiny',
'website': 'http://www.openerp.com',
'depends': ['base', 'base_action_rule',
'process',
'mail_gateway',
'base_calendar',
'resource',
],
'init_xml': ['crm_data.xml',
'crm_meeting_data.xml',
'crm_claims_data.xml',
'crm_fund_data.xml',
'crm_helpdesk_data.xml',
'crm_lead_data.xml',
'crm_meeting_data.xml',
'crm_opportunity_data.xml',
'crm_phonecall_data.xml',
'depends': [
'base',
'base_action_rule',
'process',
'mail_gateway',
'base_calendar',
'resource',
],
'init_xml': [
'crm_data.xml',
'crm_meeting_data.xml',
'crm_claims_data.xml',
'crm_fund_data.xml',
'crm_helpdesk_data.xml',
'crm_lead_data.xml',
'crm_meeting_data.xml',
'crm_opportunity_data.xml',
'crm_phonecall_data.xml',
],
'update_xml': [
@ -104,7 +107,6 @@ between mails and Open ERP.""",
'report/crm_phonecall_report_view.xml',
'process/crm_configuration_process.xml',
],
'demo_xml': [
'crm_demo.xml',
@ -114,7 +116,8 @@ between mails and Open ERP.""",
'crm_lead_demo.xml',
'crm_meeting_demo.xml',
'crm_opportunity_demo.xml',
'crm_phonecall_demo.xml'],
'crm_phonecall_demo.xml'
],
'installable': True,
'active': False,
'certificate': '0079056041421',

View File

@ -64,6 +64,8 @@ class crm_case_section(osv.osv):
'parent_id': fields.many2one('crm.case.section', 'Parent Section'),
'child_ids': fields.one2many('crm.case.section', 'parent_id', 'Child Sections'),
'resource_calendar_id': fields.many2one('resource.calendar', "Resource's Calendar"),
'server_id':fields.many2one('email.smtpclient', 'Server ID'),
'note': fields.text('Description'),
}
_defaults = {

View File

@ -72,7 +72,7 @@ class crm_cases(osv.osv):
self._history(cr, uid, cases, _('Receive'), history=True, details=body, email_from=msg_from, message_id=msg.get('id'))
return res
def message_update(self, cr, uid, ids, msg, default_act='pending', context={}):
def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}):
"""
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -80,7 +80,6 @@ class crm_cases(osv.osv):
@param ids: List of update mails IDs
"""
vals = { }
if isinstance(ids, (str, int, long)):
ids = [ids]
@ -102,7 +101,7 @@ class crm_cases(osv.osv):
res = self.write(cr, uid, ids, vals)
cases = self.browse(cr, uid, ids)
message_id = context.get('message_id', False)
message_id = context.get('references_id', False)
self._history(cr, uid, cases, _('Receive'), history=True, details=msg['body'], email_from=msg_from, message_id=message_id)
#getattr(self, act)(cr, uid, select)
return res

View File

@ -11,16 +11,31 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Case Section">
<notebook>
<group col="6" colspan="4">
<field name="name" select="1" colspan="4"/>
<field name="code" select="1"/>
<newline/>
<field name="resource_calendar_id" select="2"/>
</group>
<notebook colspan="4">
<page string="Case section">
<field name="name" select="1"/>
<field name="code" select="1"/>
<field name="user_id" select="2"/>
<field name="active" select="2"/>
<field name="parent_id" select="2" widget="selection"/>
<field name="allow_unlink" select="2"/>
<field name="reply_to" select="2"/>
<field name="resource_calendar_id" select="2"/>
<group col="2" colspan="2">
<separator string="Responsible" colspan="2"/>
<field name="parent_id" select="2" widget="selection"/>
<field name="user_id" select="2"/>
</group>
<group col="2" colspan="2">
<separator string="Contact Information" colspan="2"/>
<field name="server_id" select="2"/>
<field name="reply_to" select="2"/>
</group>
<group col="2" colspan="2">
<separator string="Section Property" colspan="2"/>
<field name="active" select="2"/>
<field name="allow_unlink" select="2"/>
</group>
<separator string="Note" colspan="4"/>
<field name="note" select="1" colspan="4" nolabel="1"/>
</page>
</notebook>
</form>

View File

@ -282,7 +282,7 @@ class email_parser(object):
if actions['state'] in ['draft', 'close', 'cancel', 'open', 'pending']:
act = 'case_' + actions['state']
for k1, k2 in [('cost', 'planned_cost'), ('revenue', 'planned_revenue'), ('probability', 'probability')]:
for k1, k2 in [('cost', 'planned_cost'), ('revenue', 'planned_revenue'), ('probability', 'probability')]:
try:
data[k2] = float(actions[k1])
except:

View File

@ -56,6 +56,7 @@ class crm_send_new_email(osv.osv_memory):
"""
hist_obj = self.pool.get('crm.case.history')
smtp_pool = self.pool.get('email.smtpclient')
if not context:
context = {}
@ -73,8 +74,8 @@ class crm_send_new_email(osv.osv_memory):
message_id = None
case = case_pool.browse(cr, uid, res_id)
if context.get('mail', 'new') == 'new':
case = case_pool.browse(cr, uid, res_id)
message_id = case.history_line[0].message_id
else:
hist = hist_obj.browse(cr, uid, res_id)
@ -91,19 +92,34 @@ class crm_send_new_email(osv.osv_memory):
case_pool._history(cr, uid, [case], _('Send'), history=True, email=data['email_to'], details=body, email_from=email_from, message_id=message_id)
x_headers = {
'References':"%s" % (message_id)
'References':"%s" % (message_id),
'Reply-To':"%s" % case.section_id.reply_to,
}
flag = tools.email_send(
email_from,
emails,
data['subject'],
body,
attach=attach,
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
x_headers=x_headers
)
flag = False
if case.section_id and case.section_id.server_id:
flag = smtp_pool.send_email(
cr=cr,
uid=uid,
server_id=case.section_id.server_id.id,
emailto=emails,
subject=data['subject'],
body="<pre>%s</pre>" % body,
attachments=attach,
headers=x_headers
)
else:
flag = tools.email_send(
email_from,
emails,
data['subject'],
body,
attach=attach,
reply_to=case.section_id.reply_to,
openobject_id=str(case.id),
x_headers=x_headers
)
if flag:
if data['state'] == 'unchanged':
pass