[IMP] hr_holidays: onboarding improvements

- labelling
- check_holidays does not raise anymore, the constraint is responsible of doing it
- cleaning of holidays status form view
- number of remaining days on an employee is now in technical feature, leave
summary exist to have statistics
This commit is contained in:
Mitesh Savani
2015-01-20 17:05:56 +01:00
committed by Thibault Delavallée
parent d8371cf674
commit 9a7dd4b827
2 changed files with 21 additions and 28 deletions
+8 -9
View File
@@ -202,8 +202,8 @@ class hr_holidays(osv.osv):
\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.'),
'payslip_status': fields.boolean(string='Payslip Status',
help='Check this field when the leave has been taken into account in the payslip.'),
'payslip_status': fields.boolean(string='Reported in last payslips',
help='Green this button when the leave has been taken into account in the payslip.'),
'report_note': fields.text('HR Comments'),
'user_id':fields.related('employee_id', 'user_id', type='many2one', relation='res.users', string='User', store=True),
'date_from': fields.datetime('Start Date', readonly=True, states={'draft':[('readonly',False)], 'confirm':[('readonly',False)]}, select=True, copy=False),
@@ -238,10 +238,11 @@ class hr_holidays(osv.osv):
'payslip_status': False,
}
_constraints = [
(_check_date, 'You can not have 2 leaves that overlaps on same day!', ['date_from','date_to']),
(_check_holidays, 'The number of remaining leaves is not sufficient for this leave type', ['state','number_of_days_temp'])
]
(_check_date, 'You can not have 2 leaves that overlaps on same day!', ['date_from', 'date_to']),
(_check_holidays, 'The number of remaining leaves is not sufficient for this leave type.\n'
'Please verify also the leaves waiting for validation.', ['state', 'number_of_days_temp'])
]
_sql_constraints = [
('type_value', "CHECK( (holiday_type='employee' AND employee_id IS NOT NULL) or (holiday_type='category' AND category_id IS NOT NULL))",
"The employee or employee category of this request is missing. Please make sure that your user login is linked to an employee."),
@@ -479,9 +480,7 @@ class hr_holidays(osv.osv):
continue
leave_days = self.pool.get('hr.holidays.status').get_days(cr, uid, [record.holiday_status_id.id], record.employee_id.id, context=context)[record.holiday_status_id.id]
if leave_days['remaining_leaves'] < 0 or leave_days['virtual_remaining_leaves'] < 0:
# Raising a warning gives a more user-friendly feedback than the default constraint error
raise UserError(_('The number of remaining leaves is not sufficient for this leave type.\n'
'Please verify also the leaves waiting for validation.'))
return False
return True
def toggle_payslip_status(self, cr, uid, ids, context=None):
+13 -19
View File
@@ -104,7 +104,7 @@
<field name="holiday_type" on_change="onchange_type(holiday_type)" attrs="{'readonly':[('type', '=', 'remove'),('state','!=','draft')]}" string="Mode" groups="base.group_hr_user" context="{'employee_id':employee_id}" />
<field name="employee_id" attrs="{'required':[('holiday_type','=','employee')],'invisible':[('holiday_type','=','category')]}" on_change="onchange_employee(employee_id)" groups="base.group_hr_user"/>
<field name="category_id" attrs="{'required':[('holiday_type','=','category')], 'readonly': [('type', '=', 'remove'),('state','!=','draft'), ('state','!=','confirm')], 'invisible':[('holiday_type','=','employee')]}"/>
<field name="department_id" attrs="{'readonly':['|', ('type','=','add'),('holiday_type','=','category')],'invisible':[('holiday_type','=','category')]}" groups="base.group_hr_user"/>
<field name="department_id" groups="base.group_hr_user" attrs="{'readonly':['|','|' ,('type','=','add'),('holiday_type','=','category'),('state','=', 'validate')],'invisible':[('holiday_type','=','category')]}"/>
<field name="payslip_status" groups="base.group_hr_manager" attrs="{'invisible':[('type','=','add')]}" widget="toggle_button"/>
</group>
<field name="notes" nolabel="1" colspan="4" placeholder="Add a reason..." attrs="{'invisible': [('type', '=', 'remove')]}"/>
@@ -442,24 +442,18 @@
<field name="model">hr.holidays.status</field>
<field name="arch" type="xml">
<form string="Leave Type">
<group col="4">
<field name="name"/>
<field name="categ_id"/>
<group>
<group name="selection">
<field name="name"/>
<field name="double_validation"/>
<field name="limit"/>
</group>
<group name="second">
<field name="categ_id"/>
<field name="color_name"/>
<field name="active"/>
</group>
</group>
<notebook>
<page string="Details">
<group>
<group name="selection" string="Validation">
<field name="double_validation"/>
<field name="limit"/>
</group>
<group name="second" string="Misc">
<field name="color_name"/>
<field name="active"/>
</group>
</group>
</page>
</notebook>
</form>
</field>
</record>
@@ -585,7 +579,7 @@
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='active_group']" position="before">
<group string="Leaves">
<group string="Leaves" groups="base.group_no_one">
<label for="remaining_leaves"/>
<div>
<field name="remaining_leaves" class="oe_inline"/> days