**Impacted versions:**
11.0

**Steps to reproduce:**
In runbot odoo/odoo or odoo/enterprise

- In Preferences change the timezone to America/Mexico_city

- Create a contract for a user with this values: **state**: running, **End Date**: NULL, **Start Date**: year before (for example), and **working schedule**: Standard 40 Hours/week
![image](https://user-images.githubusercontent.com/19410285/35942162-2640db56-0c2b-11e8-8714-b25413d62123.png)

- Edit the working schedule as the image below, and save.
![image](https://user-images.githubusercontent.com/19410285/35942368-c846cf82-0c2b-11e8-9a26-753ded2509d1.png)

- Create a payslip for a user with the edited contract.

- Change the date_from (in period) to a saturday day
![image](https://user-images.githubusercontent.com/19410285/35942575-83626d08-0c2c-11e8-8023-11675d29c3ea.png)


**Current behavior:**
Take this error
![image](https://user-images.githubusercontent.com/19410285/35942631-ad048268-0c2c-11e8-9147-c3f2ff5770fe.png)


**Expected behavior:**
compute the number of days without error


**Video/Screenshot link (optional):**
https://youtu.be/fQWTg7LXD2g

""" Return the number of leave days for the resource, taking into account
        attendances. An optional calendar can be given in case multiple calendars
        can be used on the resource. """
        days_count = 0.0
        calendar = calendar or self.resource_calendar_id
        for day_intervals in calendar._iter_leave_intervals(from_datetime, to_datetime, self.resource_id.id):
            theoric_hours = self.get_day_work_hours_count(day_intervals[0][0].date(), calendar=calendar)
            leave_time = sum((interval[1] - interval[0] for interval in day_intervals), timedelta())
            days_count += float_utils.round((leave_time.total_seconds() / 3600 / theoric_hours) * 4) / 4
        return days_count
    def iter_leaves(self, from_datetime, to_datetime, calendar=None):
        calendar = calendar or self.resource_calendar_id
        return calendar._iter_leave_intervals(from_datetime, to_datetime, self.resource_id.id)
    def get_start_work_hour(self, day_dt, calendar=None):
        calendar = calendar or self.resource_calendar_id
        work_intervals = calendar._get_day_work_intervals(day_dt, resource_id=self.resource_id.id)
        return work_intervals and work_intervals[0][0]
    def get_end_work_hour(self, day_dt, calendar=None):
        calendar = calendar or self.resource_calendar_id
        work_intervals = calendar._get_day_work_intervals(day_dt, resource_id=self.resource_id.id)
        return work_intervals and work_intervals[-1][1]
    def get_day_work_hours_count(self, day_date, calendar=None):
        calendar = calendar or self.resource_calendar_id
        attendances = calendar._get_day_attendances(day_date, False, False)
        if not attendances:
            return 0
        return sum(float(i.hour_to) - float(i.hour_from) for i in attendances)