From cbd25c5ef4010733b05318d29e7f066b656e15aa Mon Sep 17 00:00:00 2001 From: "Jiten (OpenERP)" Date: Wed, 14 Mar 2012 15:50:13 +0530 Subject: [PATCH] [IMP] Improved hr_recruitment to add social chatter notification messages. bzr revid: jra@tinyerp.com-20120314102013-olp0cdot5w93a8b7 --- addons/hr_recruitment/hr_recruitment.py | 77 ++++++++++++++----------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 2a6bc0db64c..4bd4d229ed0 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -391,49 +391,60 @@ class hr_applicant(crm.crm_case, osv.osv): self.message_append_dict(cr, uid, ids, msg, context=context) return res - def _case_open_notification(self, case, context=None): - message = _("Changed Status to In Progress.") - case.message_append_note('' ,message, type='notification') - return True - - def _case_close_notification(self, case, context=None): - case[0].message_mark_done(context) - if case[0].emp_id: - message = _("Applicant is Hired and employee created.") - case[0].message_append_note('' ,message, type='notification') - else: - message = _("Applicant is Hired.") - case[0].message_append_note('' ,message, type='notification') - return True - - def _case_cancel_notification(self, case, context=None): - case[0].message_mark_done(context=context) - message = _("Applicant is Cancelled.") - case[0].message_append_note('' ,message, type="notification") - return True - - def _case_pending_notification(self, case, context=None): - message = _("Changed Status to Pending.") - case[0].message_append_note('' ,message, type='notification') - return True - - def _case_reset_notification(self, cr, uid, ids, context=None): + def case_open_send_note(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids, context=context): - self.message_append_note(cr, uid, ids, _('System notification'), - _("Changed Status to New."), type='notification', need_action_user_id=obj.user_id.id, context=context) + message = _("Changed Status to In Progress.") + obj.message_append_note('' ,message) return True - def create_notificate(self, cr, uid, ids, context=None): + def case_close_send_note(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + if obj.emp_id: + message = _("Applicant is hired and employee created.") + obj.message_append_note('', message) + else: + message = _("Applicant is hired.") + obj.message_append_note('' ,message) + return True + + def case_cancel_send_note(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + message = _("Applicant is cancelled.") + obj.message_append_note('' ,message) + return True + + def case_pending_send_note(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + message = _("Changed Status to pending.") + obj.message_append_note('' ,message) + return True + + def case_reset_send_note(self, cr, uid, ids, context=None): + for obj in self.browse(cr, uid, ids, context=context): + message =_("Changed Status to new.") + obj.message_append_note('' ,message) + return True + + def get_needaction_user_id(self, cr, uid, ids, name, arg, context=None): + result = {} + for obj in self.browse(cr, uid, ids, context=context): + result[obj.id] = False + if (obj.state == 'draft' and obj.user_id): + result[obj.id] = obj.user_id.id + return result + + def case_create_send_note(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) + message = _("Applicant has been created.") self.message_append_note(cr, uid, ids, _('System notification'), - _("Applicant is Created."), type='notification', need_action_user_id=obj.user_id.id, context=context) + message, type='notification', context=context) return True def create(self, cr, uid, vals, context=None): obj_id = super(hr_applicant, self).create(cr, uid, vals, context=context) - self.create_notificate(cr, uid, [obj_id], context=context) + self.case_create_send_note(cr, uid, [obj_id], context=context) return obj_id def case_open(self, cr, uid, ids, context=None): @@ -496,7 +507,7 @@ class hr_applicant(crm.crm_case, osv.osv): """ res = super(hr_applicant, self).case_reset(cr, uid, ids, context) self.write(cr, uid, ids, {'date_open': False, 'date_closed': False}) - self._case_reset_notification(cr, uid, ids, context) + self.case_reset_send_note(cr, uid, ids, context) return res def set_priority(self, cr, uid, ids, priority, *args):