From 863f46ec71a61f26a03959443db2c42bbc17c01e Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Tue, 25 Apr 2017 11:01:33 +0200 Subject: [PATCH] [FIX] resource: conditions on id Don't check ids with "id is None" statements, as it won't match if id is False. This caused some bugs with MRP when confirming a MO with no calendar defined, if mrp_operations was installed. --- addons/resource/resource.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/resource/resource.py b/addons/resource/resource.py index 09a5c2f3add..5a2b3559497 100644 --- a/addons/resource/resource.py +++ b/addons/resource/resource.py @@ -179,7 +179,7 @@ class resource_calendar(osv.osv): def get_weekdays(self, cr, uid, id, default_weekdays=None, context=None): """ Return the list of weekdays that contain at least one working interval. If no id is given (no calendar), return default weekdays. """ - if id is None: + if not id: return default_weekdays if default_weekdays is not None else [0, 1, 2, 3, 4] calendar = self.browse(cr, uid, id, context=None) weekdays = set() @@ -329,7 +329,7 @@ class resource_calendar(osv.osv): work_dt = start_dt.replace(hour=0, minute=0, second=0) # no calendar: try to use the default_interval, then return directly - if id is None: + if not id: working_interval = [] if default_interval: working_interval = (start_dt.replace(hour=default_interval[0], minute=0, second=0), start_dt.replace(hour=default_interval[1], minute=0, second=0)) @@ -448,7 +448,7 @@ class resource_calendar(osv.osv): working_intervals = self.get_working_intervals_of_day(cr, uid, id, **call_args) - if id is None and not working_intervals: # no calendar -> consider working 8 hours + if not id and not working_intervals: # no calendar -> consider working 8 hours remaining_hours -= 8.0 elif working_intervals: if backwards: @@ -541,7 +541,7 @@ class resource_calendar(osv.osv): compute_leaves=compute_leaves, resource_id=resource_id, default_interval=default_interval, context=context) - if id is None or working_intervals: # no calendar -> no working hours, but day is considered as worked + if not id or working_intervals: # no calendar -> no working hours, but day is considered as worked planned_days += 1 intervals += working_intervals # get next day