[REF] Hr_holidays: used track_visibility and _track, removed extra chatter messages.
bzr revid: tde@openerp.com-20121218164217-0kn9hu9yrgkl0x8n
This commit is contained in:
@@ -21,7 +21,8 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import datetime, time
|
||||
import datetime
|
||||
import time
|
||||
from itertools import groupby
|
||||
from operator import itemgetter
|
||||
|
||||
@@ -102,13 +103,19 @@ class hr_holidays_status(osv.osv):
|
||||
res.append((record.id, name))
|
||||
return res
|
||||
|
||||
hr_holidays_status()
|
||||
|
||||
class hr_holidays(osv.osv):
|
||||
_name = "hr.holidays"
|
||||
_description = "Leave"
|
||||
_order = "type desc, date_from asc"
|
||||
_inherit = [ 'mail.thread','ir.needaction_mixin']
|
||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||
_track = {
|
||||
'state': {
|
||||
'hr_holidays.mt_holidays_approved': lambda self, cr, uid, obj, ctx=None: obj.state == 'validate',
|
||||
'hr_holidays.mt_holidays_refused': lambda self, cr, uid, obj, ctx=None: obj.state == 'refuse',
|
||||
'hr_holidays.mt_holidays_confirmed': lambda self, cr, uid, obj, ctx=None: obj.state == 'confirm',
|
||||
},
|
||||
}
|
||||
|
||||
def _employee_get(self, cr, uid, context=None):
|
||||
ids = self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context)
|
||||
@@ -135,7 +142,8 @@ class hr_holidays(osv.osv):
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64),
|
||||
'state': fields.selection([('draft', 'To Submit'), ('cancel', 'Cancelled'),('confirm', 'To Approve'), ('refuse', 'Refused'), ('validate1', 'Second Approval'), ('validate', 'Approved')],
|
||||
'Status', readonly=True, help='The status is set to \'To Submit\', when a holiday request is created.\
|
||||
'Status', readonly=True, track_visibility=1,
|
||||
help='The status is set to \'To Submit\', when a holiday request is created.\
|
||||
\nThe status is \'To Approve\', when holiday request is confirmed by user.\
|
||||
\nThe status is \'Refused\', when holiday request is refused by manager.\
|
||||
\nThe status is \'Approved\', when holiday request is approved by manager.'),
|
||||
@@ -360,7 +368,6 @@ class hr_holidays(osv.osv):
|
||||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'confirm', cr)
|
||||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'validate', cr)
|
||||
wf_service.trg_validate(uid, 'hr.holidays', leave_id, 'second_validate', cr)
|
||||
self.holidays_validate_notificate(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
def holidays_confirm(self, cr, uid, ids, context=None):
|
||||
@@ -368,7 +375,6 @@ class hr_holidays(osv.osv):
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
if record.employee_id and record.employee_id.parent_id and record.employee_id.parent_id.user_id:
|
||||
self.message_subscribe_users(cr, uid, [record.id], user_ids=[record.employee_id.parent_id.user_id.id], context=context)
|
||||
self.holidays_confirm_notificate(cr, uid, ids, context=context)
|
||||
return self.write(cr, uid, ids, {'state':'confirm'})
|
||||
|
||||
def holidays_refuse(self, cr, uid, ids, context=None):
|
||||
@@ -380,7 +386,6 @@ class hr_holidays(osv.osv):
|
||||
self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id': manager})
|
||||
else:
|
||||
self.write(cr, uid, [holiday.id], {'state': 'refuse', 'manager_id2': manager})
|
||||
self.holidays_refuse_notificate(cr, uid, ids, context=context)
|
||||
self.holidays_cancel(cr, uid, ids, context=context)
|
||||
return True
|
||||
|
||||
@@ -422,37 +427,11 @@ class hr_holidays(osv.osv):
|
||||
dom = ['|'] + dom + [('state', '=', 'validate1')]
|
||||
return dom
|
||||
|
||||
def create_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("Request <b>created</b>, waiting confirmation."), context=context)
|
||||
return True
|
||||
|
||||
def holidays_confirm_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("Request <b>submitted</b>, waiting for validation by the manager."), subtype="hr_holidays.mt_approve", context=context)
|
||||
|
||||
def holidays_first_validate_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids, context=context):
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("Request <b>approved</b>, waiting second validation."), context=context)
|
||||
|
||||
def holidays_validate_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
if obj.double_validation:
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("Request <b>validated</b>."), context=context)
|
||||
else:
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("The request has been <b>approved</b>."), subtype="hr_holidays.mt_approved", context=context)
|
||||
|
||||
def holidays_refuse_notificate(self, cr, uid, ids, context=None):
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
self.message_post(cr, uid, [obj.id],
|
||||
_("Request <b>refused</b>"), subtype="hr_holidays.mt_refused", context=context)
|
||||
|
||||
|
||||
class resource_calendar_leaves(osv.osv):
|
||||
_inherit = "resource.calendar.leaves"
|
||||
_description = "Leave Detail"
|
||||
|
||||
@@ -46,20 +46,21 @@
|
||||
</record>
|
||||
|
||||
<!-- Holidays-related subtypes for messaging / Chatter -->
|
||||
<record id="mt_approve" model="mail.message.subtype">
|
||||
<record id="mt_holidays_confirmed" model="mail.message.subtype">
|
||||
<field name="name">To Approve</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="description">Request <b>confirmed</b>, waiting confirmation</field>
|
||||
</record>
|
||||
<record id="mt_approved" model="mail.message.subtype">
|
||||
<record id="mt_holidays_approved" model="mail.message.subtype">
|
||||
<field name="name">Approved</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="description">Request <b>approved</b></field>
|
||||
</record>
|
||||
<record id="mt_refused" model="mail.message.subtype">
|
||||
<record id="mt_holidays_refused" model="mail.message.subtype">
|
||||
<field name="name">Refused</field>
|
||||
<field name="res_model">hr.holidays</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="description">Request <b>refused</b></field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
@@ -295,7 +295,7 @@ class mail_thread(osv.AbstractModel):
|
||||
if getattr(column_info.column, '_track_visibility', False) == 2
|
||||
or (getattr(column_info.column, '_track_visibility', False) == 1 and name in updated_fields))
|
||||
|
||||
def message_track(self, cr, uid, ids, updated_fields, initial_values, log_message='', context=None):
|
||||
def message_track(self, cr, uid, ids, updated_fields, initial_values, log_message='Document <b>updated</b>', context=None):
|
||||
"""
|
||||
:param list updated_fields: modified field names
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user