[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.
This commit is contained in:
parent
716ceede16
commit
863f46ec71
|
@ -179,7 +179,7 @@ class resource_calendar(osv.osv):
|
||||||
def get_weekdays(self, cr, uid, id, default_weekdays=None, context=None):
|
def get_weekdays(self, cr, uid, id, default_weekdays=None, context=None):
|
||||||
""" Return the list of weekdays that contain at least one working interval.
|
""" Return the list of weekdays that contain at least one working interval.
|
||||||
If no id is given (no calendar), return default weekdays. """
|
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]
|
return default_weekdays if default_weekdays is not None else [0, 1, 2, 3, 4]
|
||||||
calendar = self.browse(cr, uid, id, context=None)
|
calendar = self.browse(cr, uid, id, context=None)
|
||||||
weekdays = set()
|
weekdays = set()
|
||||||
|
@ -329,7 +329,7 @@ class resource_calendar(osv.osv):
|
||||||
work_dt = start_dt.replace(hour=0, minute=0, second=0)
|
work_dt = start_dt.replace(hour=0, minute=0, second=0)
|
||||||
|
|
||||||
# no calendar: try to use the default_interval, then return directly
|
# no calendar: try to use the default_interval, then return directly
|
||||||
if id is None:
|
if not id:
|
||||||
working_interval = []
|
working_interval = []
|
||||||
if default_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))
|
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)
|
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
|
remaining_hours -= 8.0
|
||||||
elif working_intervals:
|
elif working_intervals:
|
||||||
if backwards:
|
if backwards:
|
||||||
|
@ -541,7 +541,7 @@ class resource_calendar(osv.osv):
|
||||||
compute_leaves=compute_leaves, resource_id=resource_id,
|
compute_leaves=compute_leaves, resource_id=resource_id,
|
||||||
default_interval=default_interval,
|
default_interval=default_interval,
|
||||||
context=context)
|
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
|
planned_days += 1
|
||||||
intervals += working_intervals
|
intervals += working_intervals
|
||||||
# get next day
|
# get next day
|
||||||
|
|
Loading…
Reference in New Issue