[IMP] put a date for schedule a call notification,meeting notification with date in crm lead and notification with need action in crm meeting,conert phonecall into opportunity notification put.

bzr revid: bth@tinyerp.com-20120228133804-cbynhdwlw4pf1wg2
This commit is contained in:
Bhumi Thakkar (Open ERP) 2012-02-28 19:08:04 +05:30
parent c763083fc4
commit e04c1215ea
5 changed files with 44 additions and 45 deletions

View File

@ -258,6 +258,9 @@ class crm_base(object):
data.update(self.onchange_partner_address_id(cr, uid, ids, addr['contact'])['value'])
return {'value': data}
def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None):
return True
def _case_open_notification(self, case, context=None):
return True

View File

@ -274,8 +274,12 @@ class crm_lead(crm_case, osv.osv):
def _case_create_notification(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_subscribe(cr, uid, ids, [obj.user_id.id], context=context)
if obj.type=="opportunity" and obj.state=="draft":
message = _("Opportunity is <b>created</b>.")
elif obj.type=="lead" :
message = _("Lead is <b>created</b>.")
self.message_append_note(cr, uid, ids, _('System notification'),
_("Lead is <b>created</b>."), type='notification', need_action_user_id=obj.user_id.id, context=context)
message, type='notification', need_action_user_id=obj.user_id.id, context=context)
return True
def _case_open_notification(self, lead, context=None):
@ -328,13 +332,13 @@ class crm_lead(crm_case, osv.osv):
message = _("The lead is <b>escalated</b>.")
case.message_append_note('' ,message)
def _case_phonecall_notification(self, case, action, context=None):
message = _("%s a call for the opportunity %s.") % (action,case.name)
case.message_append_note('', message, need_action_user_id=case.user_id.id)
def _case_opportunity_meeting_notification(self, case, context=None):
message = _("The opportunity %s is scheduled for meeting.") % (case.name)
case.message_append_note('', message, need_action_user_id=case.user_id.id)
def _case_phonecall_notification(self, cr, uid, ids, case, phonecall, action, context=None):
for obj in phonecall.browse(cr, uid, ids, context=context):
if action == "schedule" :
message = _("<b>%s a call</b> for the %s.") % (action, obj.date)
else :
message = _("<b>%s a call</b>.") % (action)
case.message_append_note('', message)
def case_open(self, cr, uid, ids, context=None):
res = super(crm_lead, self).case_open(cr, uid, ids, context)
@ -755,7 +759,7 @@ class crm_lead(crm_case, osv.osv):
if action == 'log':
phonecall.case_close(cr, uid, [new_id])
phonecall_dict[lead.id] = new_id
self._case_phonecall_notification(lead,action,context=context)
self._case_phonecall_notification(cr, uid, [new_id], lead, phonecall, action, context=context)
return phonecall_dict
@ -873,7 +877,6 @@ class crm_lead(crm_case, osv.osv):
'search_view_id': search_view and search_view[1] or False,
'nodestroy': True
}
self._case_opportunity_meeting_notification(opp,context=context)
return value
@ -902,10 +905,10 @@ class crm_lead(crm_case, osv.osv):
for case in self.browse(cr, uid, ids, context=context):
if case.type == 'lead' or context.get('stage_type') == 'lead':
message = _("The stage of lead %s has been changed to %s.") % (case.name, stage.name)
message = _("The stage of lead has been changed to <b>%s</b>.") % (stage.name)
case.message_append_note(text, message)
elif case.type == 'opportunity':
message = _("The stage of opportunity %s has been changed to %s.") % (case.name, stage.name)
message = _("The stage of opportunity has been changed to <b>%s</b>.") % (stage.name)
case.message_append_note(text, message)
return super(crm_lead,self).write(cr, uid, ids, vals, context)

View File

@ -77,6 +77,9 @@
icon="gtk-go-forward" context="{'stage_type': 'lead'}" />
</group>
<field name="type" invisible="1"/>
<button string="Send New Email"
name="%(mail.action_email_compose_message_wizard)d"
icon="terp-mail-message-new" type="action"/>
</group>
<notebook colspan="4">
<page string="Lead">
@ -143,29 +146,6 @@
type="object" icon="gtk-convert" />
</group>
</page>
<page string="Communication &amp; History" groups="base.group_extended">
<group colspan="4">
<field colspan="4" name="email_cc" widget="char" size="512"/>
</group>
<field name="message_ids" colspan="4" nolabel="1" mode="tree" readonly="1">
<tree string="History">
<field name="display_text" string="History Information"/>
<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>
</field>
<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="%(mail.action_email_compose_message_wizard)d"
icon="terp-mail-message-new" type="action"/>
</page>
<page string="Extra Info" groups="base.group_extended">
<group colspan="2" col="2">
<separator string="Categorization" colspan="2" col="2"/>
@ -176,13 +156,6 @@
<field name="channel_id" select="1" widget="selection"/>
<field name="referred"/>
</group>
<group colspan="2" col="2">
<separator string="Dates" colspan="2" col="2"/>
<field name="create_date"/>
<field name="write_date"/>
<field name="date_open"/>
<field name="date_closed"/>
</group>
<group colspan="2" col="2">
<separator string="Mailings" colspan="2" col="2"/>
<field name="optin" on_change="on_change_optin(optin)"/>

View File

@ -80,6 +80,21 @@ class crm_meeting(crm_base, osv.osv):
'user_id': lambda self, cr, uid, ctx: uid,
}
def create(self, cr, uid, vals, context=None):
obj_id = super(crm_meeting, self).create(cr, uid, vals, context=context)
self._case_opportunity_meeting_notification(cr, uid, [obj_id], context=context)
return obj_id
def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None):
lead_obj = self.pool.get('crm.lead')
for obj in self.browse(cr, uid, ids, context=context):
if(obj.opportunity_id.id):
newid = obj.opportunity_id.id
message = _("<b>scheduled for meeting</b> %s.") % (obj.date)
for lead in lead_obj.browse(cr, uid, [newid], context=context):
lead.message_append_note('', message)
def case_open(self, cr, uid, ids, *args):
"""Confirms meeting
@param self: The object pointer

View File

@ -32,6 +32,7 @@ class crm_phonecall(crm_base, osv.osv):
_name = "crm.phonecall"
_description = "Phonecall"
_order = "id desc"
_inherit = ['mail.thread']
_columns = {
# From crm.case
'id': fields.integer('ID', readonly=True),
@ -71,12 +72,16 @@ class crm_phonecall(crm_base, osv.osv):
type="char", string="Contact", size=128),
'partner_mobile': fields.char('Mobile', size=32),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'opportunity_id': fields.many2one ('crm.lead', 'Lead/Opportunity'),
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
'opportunity_id': fields.many2one ('crm.lead', 'Lead/Opportunity'),
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
}
def create(self, cr, uid, vals, context=None):
obj_id = super(crm_phonecall, self).create(cr, uid, vals, context=context)
return obj_id
def _get_default_state(self, cr, uid, context=None):
if context and context.get('default_state', False):
return context.get('default_state')