[IMP]:removed duplicate fields from hr.employee module, put resource_id also while creating resource.calendar.leaves record when hr.holidays record is confirmed

bzr revid: pap@tinyerp.co.in-20100113104723-lcpmbsa63nv6ioam
This commit is contained in:
pap (openerp) 2010-01-13 16:17:23 +05:30
parent ebf3b96527
commit 5fe81283a1
3 changed files with 10 additions and 26 deletions

5
addons/hr/hr.py Normal file → Executable file
View File

@ -57,11 +57,6 @@ class hr_employee(osv.osv):
_description = "Employee"
_inherits = {'resource.resource':"resource_id"}
_columns = {
'name' : fields.char("Employee's Name", size=128, required=True),
'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the employee record without removing it."),
'company_id': fields.many2one('res.company', 'Company'),
'user_id' : fields.many2one('res.users', 'Related User', help='Related user name for an employee to manage his access rights.'),
'country_id' : fields.many2one('res.country', 'Nationality'),
'birthday' : fields.date("Birthday"),
'ssnid': fields.char('SSN No', size=32, help='Social Security Number'),

8
addons/hr_holidays/hr.py Normal file → Executable file
View File

@ -242,7 +242,6 @@ class hr_holidays(osv.osv):
'state':'validate',
}
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
if ids2:
vals['manager_id'] = ids2[0]
else:
@ -272,9 +271,12 @@ class hr_holidays(osv.osv):
vals= {
'name':record.name,
'date_from':record.date_from,
'date_to':record.date_to
'date_to':record.date_to,
'calendar_id':record.employee_id.calendar_id.id,
'company_id':record.employee_id.company_id.id,
'resource_id':record.employee_id.resource_id.id
}
self.pool.get('resource.calendar.leaves').create(cr,uid,vals,context)
self.pool.get('resource.calendar.leaves').create(cr,uid,vals)
return True

View File

@ -44,16 +44,13 @@ class resource_calendar(osv.osv):
resource_leave_ids = self.pool.get('resource.calendar.leaves').search(cr,uid,[('resource_id','=',resource)])
if resource_leave_ids:
res_leaves = self.pool.get('resource.calendar.leaves').read(cr,uid,resource_leave_ids,['date_from','date_to'])
print 'Leave Details',res_leaves
for i in range(len(res_leaves)):
dtf = mx.DateTime.strptime(res_leaves[i]['date_from'],'%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(res_leaves[i]['date_to'],'%Y-%m-%d %H:%M:%S')
leave_days = ((dtt - dtf).days) + 1
print 'No Of Leaves:::::::::',int(leave_days)
for x in range(int(leave_days)):
dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d'))
dt_leave.sort()
print 'Sorted Leave Dates::::',dt_leave
todo = hours
cycle = 0
result = []
@ -70,11 +67,8 @@ class resource_calendar(osv.osv):
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_to)),int((hour_to%1) * 60))
dt1 = d1.strftime('%Y-%m-%d')
dt2 = d2.strftime('%Y-%m-%d')
print 'Date 1',dt1
print 'Date 2',dt2
for i in range(len(dt_leave)):
if dt1 == dt_leave[i]:
print 'Leave::::::::'
dt_from += mx.DateTime.RelativeDateTime(days=1)
d1 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(m)),int((m%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_to)),int((hour_to%1) * 60))
@ -96,17 +90,14 @@ class resource_calendar(osv.osv):
resource_leave_ids = self.pool.get('resource.calendar.leaves').search(cr,uid,[('resource_id','=',resource)])
if resource_leave_ids:
res_leaves = self.pool.get('resource.calendar.leaves').read(cr,uid,resource_leave_ids,['date_from','date_to'])
print 'Leave Details',res_leaves
for i in range(len(res_leaves)):
dtf = mx.DateTime.strptime(res_leaves[i]['date_from'],'%Y-%m-%d %H:%M:%S')
dtt = mx.DateTime.strptime(res_leaves[i]['date_to'],'%Y-%m-%d %H:%M:%S')
no = dtt - dtf
leave_days = no.days + 1
print 'No Of Leaves:::::::::',int(leave_days)
for x in range(int(leave_days)):
dt_leave.append((dtf + mx.DateTime.RelativeDateTime(days=x)).strftime('%Y-%m-%d'))
dt_leave.sort()
print 'Sorted Leave Dates::::',dt_leave
todo = hours
cycle = 0
result = []
@ -123,11 +114,8 @@ class resource_calendar(osv.osv):
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_to)),int((hour_to%1) * 60))
dt1 = d1.strftime('%Y-%m-%d')
dt2 = d2.strftime('%Y-%m-%d')
print 'Date 1',dt1
print 'Date 2',dt2
for i in range(len(dt_leave)):
if dt1 == dt_leave[i]:
print 'Leave::::::::'
dt_from += mx.DateTime.RelativeDateTime(days=1)
d1 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(m)),int((m%1) * 60))
d2 = mx.DateTime.DateTime(dt_from.year,dt_from.month,dt_from.day,int(math.floor(hour_to)),int((hour_to%1) * 60))
@ -161,14 +149,14 @@ class resource_resource(osv.osv):
_name = "resource.resource"
_description = "Resource Detail"
_columns = {
'name' : fields.char("Name", size=64, required=True),
'name' : fields.char("Name", size=64, required=True ),
'code': fields.char('Code', size=16),
'active' : fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the resource record without removing it."),
'company_id' : fields.many2one('res.company', 'Company', required=True),
'resource_type': fields.selection([('user','Human'),('material','Material')], 'Resource Type', required=True),
'user_id' : fields.many2one('res.users', 'User'),
'time_efficiency' : fields.float('Efficiency factor', size=8, help="This field depict the efficency of the ressource to complete tasks. e.g ressource put alone on a phase of 5 days with 5 tasks assigned to him, will show a load of 100% for this phase by default, but if we put a efficency of 200%, then his load will only be 50%."),
'calendar_id' : fields.many2one("resource.calendar", "Working time", required=True, help="Define the schedule of resource"),
'user_id' : fields.many2one('res.users', 'User',help='Related user name for the resource to manage its access.'),
'time_efficiency' : fields.float('Efficiency factor', size=8, help="This field depict the efficiency of the resource to complete tasks. e.g resource put alone on a phase of 5 days with 5 tasks assigned to him, will show a load of 100% for this phase by default, but if we put a efficency of 200%, then his load will only be 50%."),
'calendar_id' : fields.many2one("resource.calendar", "Working time", help="Define the schedule of resource"),
}
_defaults = {
'resource_type' : lambda *a: 'user',
@ -183,8 +171,7 @@ class resource_calendar_leaves(osv.osv):
_description = "Leave Detail"
_columns = {
'name' : fields.char("Name", size=64),
'company_id' : fields.related('calendar_id','company_id',type='many2one',relation='res.company',string="Company",required=True),
#'company_id':fields.many2one('res.company', 'Company', required=True),
'company_id' : fields.related('calendar_id','company_id',type='many2one',relation='res.company',string="Company",readonly=True),
'calendar_id' : fields.many2one("resource.calendar", "Working time"),
'date_from' : fields.datetime('Start Date', required=True),
'date_to' : fields.datetime('End Date', required=True),