From 5fe81283a19b22f102204f539e3d1f30c8e605fe Mon Sep 17 00:00:00 2001 From: "pap (openerp)" Date: Wed, 13 Jan 2010 16:17:23 +0530 Subject: [PATCH] [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 --- addons/hr/hr.py | 5 ----- addons/hr_holidays/hr.py | 8 +++++--- addons/resource/resource.py | 23 +++++------------------ 3 files changed, 10 insertions(+), 26 deletions(-) mode change 100644 => 100755 addons/hr/hr.py mode change 100644 => 100755 addons/hr_holidays/hr.py diff --git a/addons/hr/hr.py b/addons/hr/hr.py old mode 100644 new mode 100755 index 181d783..4d77cf7 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -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'), diff --git a/addons/hr_holidays/hr.py b/addons/hr_holidays/hr.py old mode 100644 new mode 100755 index 6c5e127..a77eb04 --- a/addons/hr_holidays/hr.py +++ b/addons/hr_holidays/hr.py @@ -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 diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 2d22552..dad8aed 100755 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -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), -- 1.7.10.4