From bfc8e5e86671a67cf03d8d570058800ee2e29259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 22 Feb 2012 10:59:50 +0100 Subject: [PATCH] [IMP] hr_holidays: propagated changes in subscription mechanism. Also cleaned messages. bzr revid: tde@openerp.com-20120222095950-wnx9qfta5dh4had5 --- addons/hr_holidays/hr_holidays.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 82d3d7d51cb..78db0dc7063 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -359,30 +359,20 @@ class hr_holidays(osv.osv): # ----------------------------- def create_notificate(self, cr, uid, ids, context=None): - obj = self.browse(cr, uid, ids, context=context)[0] - self.message_append_note(cr, uid, ids, _('System notification'), - _("""The %s request '%s' has been created and is in draft mode. In this mode, it can be modified freely. \ - Click on Confirm to confirm your request and ask for its validation by the managers.""") - % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context) + for obj in self.browse(cr, uid, ids, context=context): + # add the employee and its manager if specified to the subscribed users + self.message_subscribe(cr, uid, ids, [obj.employee_id.user_id.id], context=context) + if obj.employee_id.parent_id: + self.message_subscribe(cr, uid, ids, [obj.employee_id.parent_id.user_id.id], context=context) + self.message_append_note(cr, uid, ids, _('System notification'), + _("The %s request '%s' has been created and is waiting confirmation") + % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context) return True - def message_get_subscribers(self, cr, uid, ids, context=None): - """OpenChatter: override message_get_subscribers to add : - - employee related user - - employee manager user, if it exists""" - users = super(hr_holidays, self).message_get_subscribers(cr, uid, ids, context=context) - user_ids = [] - for holidays in self.browse(cr, uid, ids, context=context): - user_ids.append(holidays.user_id.id) - if holidays.employee_id.parent_id: - user_ids.append(holidays.employee_id.parent_id.user_id.id) - users += self.pool.get('res.users').read(cr, uid, user_ids, context=context) - return users - def holidays_confirm_notificate(self, cr, uid, ids, context=None): for obj in self.browse(cr, uid, ids): self.message_append_note(cr, uid, [obj.id], _('System notification'), - _("The %s request '%s' has been confirmed. It is now waiting for validation by the manager.") + _("The %s request '%s' has been confirmed and is waiting for validation by the manager.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', need_action_user_id = obj.employee_id.parent_id.user_id.id if obj.employee_id.parent_id else False) @@ -391,7 +381,7 @@ class hr_holidays(osv.osv): self.message_mark_done(cr, uid, [obj.id], context=context) if obj.holiday_status_id.double_validation: self.message_append_note(cr, uid, [obj.id], _('System notification'), - _("The %s request '%s' has been validated. A second validation of your request is necessary and is now pending.") + _("The %s request '%s' has been validated. A second validation is necessary and is now pending.") % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context) else: self.message_append_note(cr, uid, [obj.id], _('System notification'),