Impacted versions: Odoo 10

Steps to reproduce: 
1. Create a contract for the Employee and select the Working Schedule as Day shift.

2. Go to Payroll -> Employee Payslips -> Create. Select Employee and the Contract, Period must be automatically selected. In Worked days, the WORK100 shows no of days and hours by calculating the period and Working schedule.

3. Now try selecting the previous month(1st day to last day). And the worked Days will miscalculate the no of days and hours.(Check Screenshots).

Current behavior: Miscalculation in Worked Days( No of days and Hours) if the period is change e.g. Select a last month

Expected behavior: No of days and hours must be calculated properly after changing the period.

Video/Screenshot link (optional):
![payroll_period](https://cloud.githubusercontent.com/assets/14011478/22732830/a449a954-ee15-11e6-8909-9d714d306bdb.png)
![payroll_hours](https://cloud.githubusercontent.com/assets/14011478/22732819/9e7c34e2-ee15-11e6-9924-a8dc42ce9a5a.png)



contract_ids = self.get_contract(employee, date_from, date_to)
        if not contract_ids:
            return res
        contract = self.env['hr.contract'].browse(contract_ids[0])
        res['value'].update({
            'contract_id': contract.id
        })
        struct = contract.struct_id
        if not struct:
            return res
        res['value'].update({
            'struct_id': struct.id,
        })
        
        worked_days_line_ids = self.get_worked_day_lines(contract_ids, date_from, date_to)
        input_line_ids = self.get_inputs(contract_ids, date_from, date_to)
        res['value'].update({
            'worked_days_line_ids': worked_days_line_ids,
            'input_line_ids': input_line_ids,
        })
        return res
    @api.onchange('employee_id', 'date_from')
    def onchange_employee(self):
        if (not self.employee_id) or (not self.date_from) or (not self.date_to):
            return
        employee = self.employee_id
        date_from = self.date_from
        date_to = self.date_to
        ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d")))