summaryrefslogtreecommitdiff
path: root/addons/project_long_term/wizard/working_calendar.py
diff options
context:
space:
mode:
authormra (Open ERP) <mra@tinyerp.com>2010-03-11 12:40:06 +0530
committermra (Open ERP) <mra@tinyerp.com>2010-03-11 12:40:06 +0530
commit072c756759ff9012cbd1b0e03ee9b18ae9dfc2d2 (patch)
tree45d4382ac6d9f8ae3ef6e987086033badba29a94 /addons/project_long_term/wizard/working_calendar.py
parent68f85a1ee2fe55671c72b7e1aabd425d4207b79f (diff)
[IMP] project_long_term: Improve the module and bug fixes and overall cleaning
bzr revid: mra@tinyerp.com-20100311071006-u6usdghqls7t4inl
Diffstat (limited to 'addons/project_long_term/wizard/working_calendar.py')
-rw-r--r--addons/project_long_term/wizard/working_calendar.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/addons/project_long_term/wizard/working_calendar.py b/addons/project_long_term/wizard/working_calendar.py
index faddcdd0011..f3474d81a58 100644
--- a/addons/project_long_term/wizard/working_calendar.py
+++ b/addons/project_long_term/wizard/working_calendar.py
@@ -18,9 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
+import datetime
import pooler
-import datetime
def convert_timeformat(cr, uid, time_string, context={}):
""" Convert input time string: 8.5 to output time string 8:30."""
@@ -32,7 +32,7 @@ def convert_timeformat(cr, uid, time_string, context={}):
converted_string = hour_part + ':' + str(round_mins)[0:2]
return converted_string
-def compute_leaves(cr, uid, calendar_id, resource_id=False, resource_calendar=False):
+def compute_leaves(cr, uid, calendar_id, resource_id=False, resource_calendar=False, context={}):
"""Compute the leaves from the working calendar of the resource.
@@ -49,12 +49,12 @@ def compute_leaves(cr, uid, calendar_id, resource_id=False, resource_calendar=Fa
leave_ids = resource_calendar_leaves_obj.search(cr, uid, ['|', ('calendar_id', '=', calendar_id),
('calendar_id', '=', resource_calendar),
('resource_id', '=', resource_id)
- ])
+ ], context=context)
else:
leave_ids = resource_calendar_leaves_obj.search(cr, uid, [('calendar_id', '=', calendar_id),
('resource_id', '=', False)
- ])
- leaves = resource_calendar_leaves_obj.read(cr, uid, leave_ids, ['date_from', 'date_to'])
+ ], context=context)
+ leaves = resource_calendar_leaves_obj.read(cr, uid, leave_ids, ['date_from', 'date_to'], context=context)
for i in range(len(leaves)):
dt_start = datetime.datetime.strptime(leaves[i]['date_from'], '%Y-%m-%d %H:%M:%S')
dt_end = datetime.datetime.strptime(leaves[i]['date_to'], '%Y-%m-%d %H:%M:%S')
@@ -63,7 +63,7 @@ def compute_leaves(cr, uid, calendar_id, resource_id=False, resource_calendar=Fa
leave_list.sort()
return leave_list
-def compute_working_calendar(cr, uid, calendar_id):
+def compute_working_calendar(cr, uid, calendar_id, context={}):
"""Change the format of working calendar from 'Openerp' format to bring it into 'Faces' format.
@@ -80,8 +80,8 @@ def compute_working_calendar(cr, uid, calendar_id):
wk_time = {}
wktime_list = []
wktime_cal = []
- week_ids = resource_week_obj.search(cr, uid, [('calendar_id', '=', calendar_id)])
- weeks = resource_week_obj.read(cr, uid, week_ids, ['dayofweek', 'hour_from', 'hour_to'])
+ week_ids = resource_week_obj.search(cr, uid, [('calendar_id', '=', calendar_id)], context=context)
+ weeks = resource_week_obj.read(cr, uid, week_ids, ['dayofweek', 'hour_from', 'hour_to'], context=context)
# Convert time formats into appropriate format required
# and create a list like [('mon', '8:00-12:00'), ('mon', '13:00-18:00')]
for week in weeks: