Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] resource: current_interval not converted into namedtuple #33406

Conversation

Projects
None yet
2 participants
@c-engelhardt-ecoservice
Copy link
Contributor

commented May 15, 2019

Description of the issue/feature this PR addresses:
While merging (calendar) intervals, the code path "union of greater intervals" does not convert the current_interval into the namedtuple "Interval" before passing it to the next method which leads to the described behavior.

Current behavior before PR:
When entering the "union of greater intervals" code path the following Traceback will be raised:

Traceback (most recent call last):
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 651, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/opt/odoo/11.0/production/odoo/community/odoo/tools/pycompat.py", line 87, in reraise
    raise value
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 693, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 342, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoo/11.0/production/odoo/community/odoo/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 335, in checked_call
    result = self.endpoint(*a, **kw)
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 937, in __call__
    return self.method(*args, **kw)
  File "/opt/odoo/11.0/production/odoo/community/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoo/11.0/production/odoo/community/addons/web/controllers/main.py", line 934, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/11.0/production/odoo/community/addons/web/controllers/main.py", line 926, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/11.0/production/odoo/community/odoo/api.py", line 687, in call_kw
    return call_kw_model(method, model, args, kwargs)
  File "/opt/odoo/11.0/production/odoo/community/odoo/api.py", line 672, in call_kw_model
    result = method(recs, *args, **kwargs)
  File "/opt/odoo/11.0/production/addons/oca/hr/hr_attendance_report_theoretical_time/reports/hr_attendance_theoretical_time_report.py", line 231, in read_group
    record.employee_id.sudo(), record.date,
  File "/opt/odoo/11.0/production/addons/oca/hr/hr_attendance_report_theoretical_time/reports/hr_attendance_theoretical_time_report.py", line 199, in _theoretical_hours
    date_date, time(23, 59, 59, 99999, tzinfo=tz.gettz(utz))
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource_mixin.py", line 57, in get_work_days_data
    compute_leaves=True):
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 440, in _iter_work_intervals
    resource_id=resource_id)
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 365, in _get_day_work_intervals
    for interval in working_intervals
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 366, in <listcomp>
    for sub_interval in self._interval_remove_leaves(interval, leaves)]
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 170, in _interval_remove_leaves
    leave_intervals = self._interval_merge(leave_intervals)
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 156, in _interval_merge
    working_interval = self._interval_or(working_interval, current_interval)
  File "/opt/odoo/11.0/production/odoo/community/addons/resource/models/resource.py", line 127, in _interval_or
    interval.start_datetime < interval_dst.start_datetime and interval.start_datetime or interval_dst.start_datetime,
AttributeError: 'tuple' object has no attribute 'start_datetime'

Desired behavior after PR is merged:
No Traceback.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo robodoo added the seen 🙂 label May 15, 2019

@c-engelhardt-ecoservice

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2019

CLA was accepted here #33370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.