[MERGE] HR fixes
bzr revid: fp@tinyerp.com-20121108092451-2jk31s913mrat1jm
This commit is contained in:
commit
574405bed8
|
@ -291,6 +291,7 @@ survey_request()
|
|||
class hr_evaluation_interview(osv.osv):
|
||||
_name = 'hr.evaluation.interview'
|
||||
_inherits = {'survey.request': 'request_id'}
|
||||
_inherit = 'mail.thread'
|
||||
_rec_name = 'request_id'
|
||||
_description = 'Appraisal Interview'
|
||||
_columns = {
|
||||
|
|
|
@ -113,6 +113,13 @@ class hr_holidays(osv.osv):
|
|||
result[hol.id] = hol.number_of_days_temp
|
||||
return result
|
||||
|
||||
def _check_date(self, cr, uid, ids):
|
||||
for holiday in self.browse(cr, uid, ids):
|
||||
holiday_ids = self.search(cr, uid, [('date_from', '<=', holiday.date_to), ('date_to', '>=', holiday.date_from), ('employee_id', '=', holiday.employee_id.id), ('id', '<>', holiday.id)])
|
||||
if holiday_ids:
|
||||
return False
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Description', size=64),
|
||||
'state': fields.selection([('draft', 'To Submit'), ('cancel', 'Cancelled'),('confirm', 'To Approve'), ('refuse', 'Refused'), ('validate1', 'Second Approval'), ('validate', 'Approved')],
|
||||
|
@ -146,6 +153,10 @@ class hr_holidays(osv.osv):
|
|||
'user_id': lambda obj, cr, uid, context: uid,
|
||||
'holiday_type': 'employee'
|
||||
}
|
||||
_constraints = [
|
||||
(_check_date, 'You can not have 2 leaves that overlaps on same day!', ['date_from','date_to']),
|
||||
]
|
||||
|
||||
_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."),
|
||||
('date_check2', "CHECK ( (type='add') OR (date_from <= date_to))", "The start date must be anterior to the end date."),
|
||||
|
@ -252,6 +263,13 @@ class hr_holidays(osv.osv):
|
|||
result['value']['number_of_days_temp'] = 0
|
||||
|
||||
return result
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
check_fnct = self.pool.get('hr.holidays.status').check_access_rights
|
||||
for holiday in self.browse(cr, uid, ids, context=context):
|
||||
if holiday.state in ('validate','validate1') and not check_fnct(cr, uid, 'write', raise_exception=False):
|
||||
raise osv.except_osv(_('Warning!'),_('You cannot modify a leave request that has been approved. Contact a human resource manager.'))
|
||||
return super(hr_holidays, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def set_to_draft(self, cr, uid, ids, context=None):
|
||||
self.write(cr, uid, ids, {
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
<record model="hr.holidays" id="hr_holidays_employee1_vc">
|
||||
<field name="name">Summer Vacation</field>
|
||||
<field name="holiday_status_id" ref="holiday_status_unpaid"/>
|
||||
<field eval="time.strftime('%Y-%m-20')" name="date_from"/>
|
||||
<field eval="time.strftime('%Y-%m-22')" name="date_to"/>
|
||||
<field eval="time.strftime('%Y-%m-23')" name="date_from"/>
|
||||
<field eval="time.strftime('%Y-%m-25')" name="date_to"/>
|
||||
<field name="type">add</field>
|
||||
<field name="state">draft</field>
|
||||
<field name="number_of_days_temp">7</field>
|
||||
|
@ -45,8 +45,8 @@
|
|||
<record model="hr.holidays" id="hr_holidays_employee1_int_tour">
|
||||
<field name="name">International Tour</field>
|
||||
<field name="holiday_status_id" ref="holiday_status_comp"/>
|
||||
<field eval="time.strftime('%Y-%m-20')" name="date_from"/>
|
||||
<field eval="time.strftime('%Y-%m-22')" name="date_to"/>
|
||||
<field eval="time.strftime('%Y-%m-26')" name="date_from"/>
|
||||
<field eval="time.strftime('%Y-%m-28')" name="date_to"/>
|
||||
<field name="type">add</field>
|
||||
<field name="number_of_days_temp">7</field>
|
||||
<field name="employee_id" ref="hr.employee_fp"/>
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
import mail_message_subtype
|
||||
import mail_alias
|
||||
import mail_followers
|
||||
import mail_favorite
|
||||
import mail_message
|
||||
import mail_mail
|
||||
import mail_thread
|
||||
import mail_group
|
||||
import mail_vote
|
||||
import mail_favorite
|
||||
import res_partner
|
||||
import res_users
|
||||
import report
|
||||
|
|
Loading…
Reference in New Issue