[MERGE] hr_holidays: set legal leaves to employee. merged the branch from aag + improved error message and allow leave request too
bzr revid: qdp-launchpad@openerp.com-20110527130904-kfk41z65ghwv97fq
This commit is contained in:
commit
de91919e21
|
@ -333,10 +333,17 @@ class hr_employee(osv.osv):
|
||||||
holiday_obj = self.pool.get('hr.holidays')
|
holiday_obj = self.pool.get('hr.holidays')
|
||||||
# Find for holidays status
|
# Find for holidays status
|
||||||
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
|
status_ids = type_obj.search(cr, uid, [('limit', '=', False)], context=context)
|
||||||
|
if len(status_ids) != 1 :
|
||||||
|
raise osv.except_osv(('warning !'),_("To use this feature, you should have only one leave type without the option 'Allow to Override Limit' set (%s Found).") % (len(status_ids)))
|
||||||
status_id = status_ids and status_ids[0] or False
|
status_id = status_ids and status_ids[0] or False
|
||||||
if not status_id or diff <= 0:
|
if not status_id:
|
||||||
|
return False
|
||||||
|
if diff > 0:
|
||||||
|
leave_id = holiday_obj.create(cr, uid, {'name': _('Allocation for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context)
|
||||||
|
elif diff < 0:
|
||||||
|
leave_id = holiday_obj.create(cr, uid, {'name': _('Leave Request for %s') % employee.name, 'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'remove', 'holiday_type': 'employee', 'number_of_days_temp': abs(diff)}, context=context)
|
||||||
|
else:
|
||||||
return False
|
return False
|
||||||
leave_id = holiday_obj.create(cr, uid, {'name': 'Allocation for ' + employee.name,'employee_id': employee.id, 'holiday_status_id': status_id, 'type': 'add', 'holiday_type': 'employee', 'number_of_days_temp': diff}, context=context)
|
|
||||||
holiday_obj.holidays_confirm(cr, uid, [leave_id])
|
holiday_obj.holidays_confirm(cr, uid, [leave_id])
|
||||||
holiday_obj.holidays_validate2(cr, uid, [leave_id])
|
holiday_obj.holidays_validate2(cr, uid, [leave_id])
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<!-- Casual leave -->
|
<!-- Casual leave -->
|
||||||
<record model="hr.holidays.status" id="holiday_status_cl">
|
<record model="hr.holidays.status" id="holiday_status_cl">
|
||||||
<field name="name">Legal Leaves</field>
|
<field name="name">Legal Leaves</field>
|
||||||
<field name="limit">False</field>
|
|
||||||
<field name="color_name">black</field>
|
<field name="color_name">black</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@
|
||||||
<!-- Compensatory Days -->
|
<!-- Compensatory Days -->
|
||||||
<record model="hr.holidays.status" id="holiday_status_comp">
|
<record model="hr.holidays.status" id="holiday_status_comp">
|
||||||
<field name="name">Compensatory Days</field>
|
<field name="name">Compensatory Days</field>
|
||||||
<field name="limit">False</field>
|
<field name="limit">True</field>
|
||||||
<field name="color_name">brown</field>
|
<field name="color_name">brown</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
|
@ -451,7 +451,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Assign Leaves" editable="top">
|
<tree string="Assign Leaves" editable="top">
|
||||||
<field name="name" string="Employee"/>
|
<field name="name" string="Employee"/>
|
||||||
<field name="remaining_leaves"/>
|
<field name="remaining_leaves" string="Remaining Legal Leaves"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
Loading…
Reference in New Issue