[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:
Quentin (OpenERP) 2011-05-27 15:09:04 +02:00
commit de91919e21
3 changed files with 11 additions and 5 deletions

View File

@ -333,10 +333,17 @@ class hr_employee(osv.osv):
holiday_obj = self.pool.get('hr.holidays')
# Find for holidays status
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
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
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_validate2(cr, uid, [leave_id])
return True

View File

@ -5,7 +5,6 @@
<!-- Casual leave -->
<record model="hr.holidays.status" id="holiday_status_cl">
<field name="name">Legal Leaves</field>
<field name="limit">False</field>
<field name="color_name">black</field>
</record>
@ -20,7 +19,7 @@
<!-- Compensatory Days -->
<record model="hr.holidays.status" id="holiday_status_comp">
<field name="name">Compensatory Days</field>
<field name="limit">False</field>
<field name="limit">True</field>
<field name="color_name">brown</field>
</record>

View File

@ -451,7 +451,7 @@
<field name="arch" type="xml">
<tree string="Assign Leaves" editable="top">
<field name="name" string="Employee"/>
<field name="remaining_leaves"/>
<field name="remaining_leaves" string="Remaining Legal Leaves"/>
</tree>
</field>
</record>