[IMP/FIX] YAMl typos and missing docstring for the reosurce calendar def
bzr revid: jam@tinyerp.com-20111129063028-0k7zkk1hrr1jd0vp
This commit is contained in:
parent
477becd62a
commit
e726b6ee40
|
@ -43,9 +43,12 @@ class resource_calendar(osv.osv):
|
|||
}
|
||||
|
||||
def working_hours_on_day(self, cr, uid, resource_calendar_id, day, context=None):
|
||||
"""
|
||||
"""Calculates the Working Total Hours based on Resource Calendar and
|
||||
given working day (datetime object).
|
||||
|
||||
@param resource_calendar_id: resource.calendar browse record
|
||||
@param day: datetime object
|
||||
|
||||
@return: returns the working hours (as float) men should work on the given day if is in the attendance_ids of the resource_calendar_id (i.e if that day is a working day), returns 0.0 otherwise
|
||||
"""
|
||||
res = 0.0
|
||||
|
@ -55,9 +58,16 @@ class resource_calendar(osv.osv):
|
|||
return res
|
||||
|
||||
def _get_leaves(self, cr, uid, id, resource):
|
||||
"""Private Method to Calculate resource Leaves days
|
||||
|
||||
@param id: resource calendar id
|
||||
@param resource: resource id for which leaves will ew calculated
|
||||
|
||||
@return : returns the list of dates, where resource on leave in
|
||||
resource.calendar.leaves object (e.g.['%Y-%m-%d', '%Y-%m-%d'])
|
||||
"""
|
||||
resource_cal_leaves = self.pool.get('resource.calendar.leaves')
|
||||
dt_leave = []
|
||||
|
||||
resource_leave_ids = resource_cal_leaves.search(cr, uid, [('calendar_id','=',id), '|', ('resource_id','=',False), ('resource_id','=',resource)])
|
||||
#res_leaves = resource_cal_leaves.read(cr, uid, resource_leave_ids, ['date_from', 'date_to'])
|
||||
res_leaves = resource_cal_leaves.browse(cr, uid, resource_leave_ids)
|
||||
|
@ -72,6 +82,21 @@ class resource_calendar(osv.osv):
|
|||
return dt_leave
|
||||
|
||||
def interval_min_get(self, cr, uid, id, dt_from, hours, resource=False):
|
||||
"""
|
||||
Calculates the working Schedule from supplied from date to till hours
|
||||
will be satisfied based or resource calendar id. If resource is also
|
||||
given then it will consider the resource leave also and than will
|
||||
calculates resource working schedule
|
||||
|
||||
@param dt_from: datetime object, start of working scheduled
|
||||
@param hours: float, total number working hours needed scheduled from
|
||||
start date
|
||||
@param resource : Optional Resource id, if supplied than resource leaves
|
||||
will also taken into consideration for calculating working
|
||||
schedule.
|
||||
@return : List datetime object of working schedule based on supplies
|
||||
params
|
||||
"""
|
||||
if not id:
|
||||
td = int(hours)*3
|
||||
return [(dt_from - timedelta(hours=td), dt_from)]
|
||||
|
@ -161,10 +186,32 @@ class resource_calendar(osv.osv):
|
|||
return results
|
||||
|
||||
def interval_get(self, cr, uid, id, dt_from, hours, resource=False, byday=True):
|
||||
"""Calculates Resource Working Internal Timing Based on Resource Calendar.
|
||||
|
||||
@param dt_from: start resource schedule calculation.
|
||||
@param hours : total number of working hours to be scheduled.
|
||||
@param resource: optional resource id, If supplied it will take care of
|
||||
resource leave while scheduling.
|
||||
@param byday: boolean flag bit enforce day wise scheduling
|
||||
|
||||
@return : list of scheduled working timing based on resource calendar.
|
||||
"""
|
||||
res = self.interval_get_multi(cr, uid, [(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)], resource, byday)[(dt_from.strftime('%Y-%m-%d %H:%M:%S'), hours, id)]
|
||||
return res
|
||||
|
||||
def interval_hours_get(self, cr, uid, id, dt_from, dt_to, resource=False):
|
||||
""" Calculates the Total Working hours based on given start_date to
|
||||
end_date, If resource id is supplied that it will consider the source
|
||||
leaves also in calculating the hours.
|
||||
|
||||
@param dt_from : date start to calculate hours
|
||||
@param dt_end : date end to calculate hours
|
||||
@param resource: optional resource id, If given resource leave will be
|
||||
considered.
|
||||
|
||||
@return : Total number of working hours based dt_from and dt_end and
|
||||
resource if supplied.
|
||||
"""
|
||||
if not id:
|
||||
return 0.0
|
||||
dt_leave = self._get_leaves(cr, uid, id, resource)
|
||||
|
@ -289,6 +336,7 @@ class resource_resource(osv.osv):
|
|||
def compute_vacation(self, cr, uid, calendar_id, resource_id=False, resource_calendar=False, context=None):
|
||||
"""
|
||||
Compute the vacation from the working calendar of the resource.
|
||||
|
||||
@param calendar_id : working calendar of the project
|
||||
@param resource_id : resource working on phase/task
|
||||
@param resource_calendar : working calendar of the resource
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
result = self.working_hours_on_day(cr, uid, calendar, dt, context)
|
||||
assert result, "No Working Our on Day for Resource has been Generated."
|
||||
-
|
||||
I Check the Resource 6.0 Hours Working Internal Timeming Based on Resource Calendar.
|
||||
I Check the Resource 6.0 Hours Working Internal Timing Based on Resource Calendar.
|
||||
-
|
||||
!python {model: resource.calendar}: |
|
||||
from datetime import datetime
|
||||
dt = datetime.now()
|
||||
result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0)
|
||||
result = self.interval_get(cr, uid, ref('timesheet_group1'), dt, 6.0, ref('resource_resource_demorsource'))
|
||||
assert result, 'No Working Internal Timeming Generated'
|
||||
|
||||
-
|
||||
|
|
Loading…
Reference in New Issue