[FIX] hr_holidays
bzr revid: fp@tinyerp.com-20111001225958-0d0wi1los2870utr
This commit is contained in:
parent
1475aa0ea1
commit
5dc1bc2f44
|
@ -358,12 +358,24 @@ class hr_employee(osv.osv):
|
|||
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
|
||||
holiday_obj.holidays_confirm(cr, uid, [leave_id])
|
||||
holiday_obj.holidays_validate2(cr, uid, [leave_id])
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
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)
|
||||
return True
|
||||
|
||||
def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
|
||||
cr.execute("SELECT sum(h.number_of_days_temp) as days, h.employee_id from hr_holidays h join hr_holidays_status s on (s.id=h.holiday_status_id) where h.type='add' and h.state='validate' and s.limit=False group by h.employee_id")
|
||||
cr.execute("""SELECT
|
||||
sum(h.number_of_days) as days,
|
||||
h.employee_id
|
||||
from
|
||||
hr_holidays h
|
||||
join hr_holidays_status s on (s.id=h.holiday_status_id)
|
||||
where
|
||||
h.state='validate' and
|
||||
s.limit=False and
|
||||
h.employee_id in (%s)
|
||||
group by h.employee_id""", (','.join(map(str,ids)),) )
|
||||
res = cr.dictfetchall()
|
||||
remaining = {}
|
||||
for r in res:
|
||||
|
@ -373,9 +385,8 @@ class hr_employee(osv.osv):
|
|||
remaining[employee_id] = 0.0
|
||||
return remaining
|
||||
|
||||
|
||||
_columns = {
|
||||
'remaining_leaves': fields.function(_get_remaining_days, string='Remaining Legal Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave requests.', store=True),
|
||||
'remaining_leaves': fields.function(_get_remaining_days, string='Remaining Legal Leaves', fnct_inv=_set_remaining_days, type="float", help='Total number of legal leaves allocated to this employee, change this value to create allocation/leave requests.'),
|
||||
}
|
||||
|
||||
hr_employee()
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<group>
|
||||
<filter icon="terp-check" domain="[('state','=','draft')]" string="To Confirm"/>
|
||||
<filter icon="terp-camera_test" domain="[('state','=','confirm')]" string="To Approve"/>
|
||||
<filter icon="terp-camera_test" domain="[('state','=','validate')]" string="Validated"/>
|
||||
<filter icon="terp-camera_test" domain="[('state','=','validate')]" string="Validated" name="validated"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="This Month" icon="terp-go-month" name="This Month" domain="[('date_from','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('date_from','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]"/>
|
||||
<separator orientation="vertical"/>
|
||||
|
@ -21,8 +21,6 @@
|
|||
<filter icon="terp-personal+" help="My Department Leaves" domain="[('department_id.manager_id','=',uid)]"/>
|
||||
</field>
|
||||
<field name="holiday_status_id" widget="selection"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By...">
|
||||
|
@ -314,7 +312,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" eval="view_holiday_simple"/>
|
||||
<field name="context">{'search_default_my_leaves': 1, 'search_default_group_type': 1}</field>
|
||||
<field name="context">{'search_default_my_leaves': 1, 'search_default_group_type': 1, 'search_default_validated': 1}</field>
|
||||
<field name="domain">[('holiday_type','=','employee')]</field>
|
||||
<field name="search_view_id" ref="view_hr_holidays_filter"/>
|
||||
</record>
|
||||
|
@ -437,7 +435,7 @@
|
|||
<field name="model">hr.employee</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Assign Leaves" editable="top">
|
||||
<tree string="Assign Leaves" editable="bottom">
|
||||
<field name="name" string="Employee"/>
|
||||
<field name="remaining_leaves" string="Remaining Legal Leaves"/>
|
||||
</tree>
|
||||
|
@ -467,7 +465,7 @@
|
|||
<field name="inherit_id" ref="hr.view_employee_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="coach_id" position="after">
|
||||
<field name="remaining_leaves" string="Remaining Legal Leaves"/>
|
||||
<field name="remaining_leaves" string="Remaining Legal Leaves" readonly="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue