[IMP] notification for crm meeting and crm phonecall.

bzr revid: bth@tinyerp.com-20120306091855-b7kx0wxxcu81uw0d
This commit is contained in:
Bhumi Thakkar (Open ERP) 2012-03-06 14:48:55 +05:30
parent 0688cc33a2
commit da087c47b0
6 changed files with 74 additions and 13 deletions

View File

@ -273,6 +273,9 @@ class crm_base(object):
def _case_pending_notification(self, case, context=None):
return True
def _case_reset_notification(self, case, context=None):
return True
def _case_escalate_notification(self, case, context=None):
return True
@ -336,6 +339,7 @@ class crm_base(object):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.write(cr, uid, ids, {'state': 'draft', 'active': True})
self._case_reset_notification(cases, context=context)
self._action(cr, uid, cases, 'draft')
return True
@ -485,6 +489,7 @@ class crm_case(crm_base):
cases = self.browse(cr, uid, ids)
cases[0].state # to fill the browse record cache
self.write(cr, uid, ids, {'state': state, 'active': True})
self._case_reset_notification(cases, context=context);
self._action(cr, uid, cases, state)
return True

View File

@ -334,6 +334,13 @@ class crm_lead(crm_case, osv.osv):
message = _("The lead is <b>escalated</b>.")
case.message_append_note('' ,message)
def _case_reset_notification(self, case, context=None):
if case[0].type == 'lead':
message = _("The lead is <b>renewed</b>.")
elif case[0].type == 'opportunity':
message = _("The opportunity is <b>renewed</b>.")
case[0].message_append_note('' ,message, need_action_user_id=case[0].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" :

View File

@ -42,7 +42,7 @@ class crm_meeting(crm_base, osv.osv):
_name = 'crm.meeting'
_description = "Meeting"
_order = "id desc"
_inherit = "calendar.event"
_inherit = ["calendar.event","mail.thread"]
_columns = {
# From crm.case
'name': fields.char('Summary', size=124, required=True, states={'done': [('readonly', True)]}),
@ -87,15 +87,37 @@ class crm_meeting(crm_base, osv.osv):
def _case_opportunity_meeting_notification(self, cr, uid, ids, context=None):
lead_obj = self.pool.get('crm.lead')
phonecall_obj = self.pool.get('crm.phonecall')
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)
message = _("<b>scheduled meeting on</b> %s for opportunity.") % (obj.date)
for lead in lead_obj.browse(cr, uid, [newid], context=context):
lead.message_append_note('', message)
obj.message_append_note('', message, need_action_user_id=lead.user_id.id)
elif(obj.phonecall_id.id):
newid = obj.phonecall_id.id
message = _("<b>scheduled meeting on</b> %s for phonecall.") % (obj.date)
for phonecall in phonecall_obj.browse(cr, uid, [newid], context=context):
phonecall.message_append_note('', message)
obj.message_append_note('', message, need_action_user_id=phonecall.user_id.id)
def case_open(self, cr, uid, ids, *args):
def _case_close_notification(self, meeting, context=None):
meeting[0].message_mark_done(context)
message = _("The meeting is <b>done</b>.")
meeting[0].message_append_note('' ,message)
def _case_reset_notification(self, meeting, context=None):
message = _("The meeting is <b>unconfirmed</b>.")
meeting[0].message_append_note('' ,message)
def _case_open_notification(self, meeting, context=None):
if meeting.state != 'draft':
return False
message = _("The meeting has been <b>confirmed</b>.")
meeting.message_append_note('' ,message, need_action_user_id=meeting.user_id.id)
def case_open(self, cr, uid, ids, context=None):
"""Confirms meeting
@param self: The object pointer
@param cr: the current row, from the database cursor,
@ -103,11 +125,9 @@ class crm_meeting(crm_base, osv.osv):
@param ids: List of Meeting Ids
@param *args: Tuple Value for additional Params
"""
res = super(crm_meeting, self).case_open(cr, uid, ids, args)
res = super(crm_meeting, self).case_open(cr, uid, ids, context)
for (id, name) in self.name_get(cr, uid, ids):
message = _("The meeting '%s' has been confirmed.") % name
id=base_calendar.base_calendar_id2real_id(id)
self.log(cr, uid, id, message)
return res
crm_meeting()

View File

@ -216,6 +216,7 @@
</page>
</notebook>
<field name="message_ids_social" widget="ThreadView"/>
</form>
</field>
</record>

View File

@ -80,6 +80,7 @@ class crm_phonecall(crm_base, osv.osv):
def create(self, cr, uid, vals, context=None):
obj_id = super(crm_phonecall, self).create(cr, uid, vals, context=context)
self.open_notification(cr, uid, [obj_id], context)
return obj_id
def _get_default_state(self, cr, uid, context=None):
@ -94,6 +95,29 @@ class crm_phonecall(crm_base, osv.osv):
'user_id': lambda self,cr,uid,ctx: uid,
'active': 1,
}
def _case_cancel_notification(self, phonecall, context=None):
phonecall[0].message_mark_done(context)
message = _("The Phonecall is <b>cancelled</b>.")
phonecall[0].message_append_note( _('System notification'),
message, type='notification', context=context)
def _case_pending_notification(self, phonecall, context=None):
message = _("The Phonecall is <b>pending</b>.")
phonecall[0].message_append_note('' ,message)
def done_notification(self, cr, uid, ids, context=None):
for phonecall in self.browse(cr, uid, ids):
phonecall.message_mark_done(context)
message = _("The Phonecall is <b>done</b>.")
self.message_append_note(cr, uid, [phonecall.id], _('System notification'),
message, type='notification', context=context)
def open_notification(self, cr, uid, ids, context=None):
for phonecall in self.browse(cr, uid, ids):
self.message_subscribe(cr, uid, ids, [phonecall.user_id.id], context=context)
message = _("The Phonecall is <b>open</b>.")
self.message_append_note(cr, uid, [phonecall.id], _('System notification'),message,
type='notification', need_action_user_id=phonecall.user_id.id, context=context)
# From crm.case
def onchange_partner_address_id(self, cr, uid, ids, add, email=False):
@ -105,7 +129,7 @@ class crm_phonecall(crm_base, osv.osv):
res['value']['partner_mobile'] = address.mobile
return res
def case_close(self, cr, uid, ids, *args):
def case_close(self, cr, uid, ids, context=None):
"""Overrides close for crm_case for setting close date
"""
res = True
@ -115,23 +139,26 @@ class crm_phonecall(crm_base, osv.osv):
if phone.duration <=0:
duration = datetime.now() - datetime.strptime(phone.date, '%Y-%m-%d %H:%M:%S')
data.update({'duration': duration.seconds/float(60)})
res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], args)
res = super(crm_phonecall, self).case_close(cr, uid, [phone_id], context)
self.write(cr, uid, [phone_id], data)
self.done_notification(cr, uid, [phone_id], context);
return res
def case_reset(self, cr, uid, ids, *args):
def case_reset(self, cr, uid, ids, context=None):
"""Resets case as Todo
"""
res = super(crm_phonecall, self).case_reset(cr, uid, ids, args)
res = super(crm_phonecall, self).case_reset(cr, uid, ids, context)
self.write(cr, uid, ids, {'duration': 0.0, 'state':'open'})
self.open_notification(cr, uid, ids, context)
return res
def case_open(self, cr, uid, ids, *args):
def case_open(self, cr, uid, ids, context=None):
"""Overrides cancel for crm_case for setting Open Date
"""
res = super(crm_phonecall, self).case_open(cr, uid, ids, *args)
res = super(crm_phonecall, self).case_open(cr, uid, ids, context)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
self.open_notification(cr, uid, ids, context)
return res
def schedule_another_phonecall(self, cr, uid, ids, schedule_time, call_summary, \

View File

@ -123,6 +123,7 @@
states="cancel" type="object"
icon="gtk-convert" />
</group>
<field name="message_ids_social" widget="ThreadView"/>
</form>
</field>
</record>