[IMP] hr_holidays: show leave duration on calendar view

name pattern like '<Employee_name> on <holiday_status> : <no_days> days'.
This commit is contained in:
Mitali Patel
2016-05-27 14:29:24 +02:00
committed by Yannick Tivisse
parent 32ed4c7191
commit d7a4cc47f9
2 changed files with 5 additions and 7 deletions
+1 -5
View File
@@ -231,7 +231,7 @@ class hr_holidays(osv.osv):
def name_get(self, cr, uid, ids, context=None):
res = []
for leave in self.browse(cr, uid, ids, context=context):
res.append((leave.id, leave.name or _("%s on %s") % (leave.employee_id.name, leave.holiday_status_id.name)))
res.append((leave.id, _("%s on %s : %.2f day(s)") % (leave.employee_id.name, leave.holiday_status_id.name, leave.number_of_days_temp)))
return res
def _create_resource_leave(self, cr, uid, leaves, context=None):
@@ -369,10 +369,6 @@ class hr_holidays(osv.osv):
context = dict(context, mail_create_nolog=True, mail_create_nosubscribe=True)
if not self._check_state_access_right(cr, uid, values, context):
raise AccessError(_('You cannot set a leave request as \'%s\'. Contact a human resource manager.') % values.get('state'))
if not values.get('name'):
employee_name = self.pool['hr.employee'].browse(cr, uid, employee_id, context=context).name
holiday_type = self.pool['hr.holidays.status'].browse(cr, uid, values.get('holiday_status_id'), context=context).name
values['name'] = _("%s on %s") % (employee_name, holiday_type)
hr_holiday_id = super(hr_holidays, self).create(cr, uid, values, context=context)
self.add_follower(cr, uid, [hr_holiday_id], employee_id, context=context)
return hr_holiday_id
+4 -2
View File
@@ -69,8 +69,7 @@
date_start="date_from" date_stop="date_to"
mode="month"
quick_add="False" avatar_model="hr.employee">
<field name="employee_id"/>
<field name="holiday_status_id"/>
<field name="display_name"/>
</calendar>
</field>
</record>
@@ -93,6 +92,9 @@
<field name="state" widget="statusbar" statusbar_visible="draft,confirm,validate" statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}'/>
</header>
<sheet>
<div class="oe_title">
<h1><field name="display_name"/></h1>
</div>
<group>
<group>
<field name="name" attrs="{'readonly':[('state','!=','draft'),('state','!=','confirm')]}"/>