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)



paid = fields.Boolean(string='Made Payment Order ? ', readonly=True, copy=False,
        states={'draft': [('readonly', False)]})
    note = fields.Text(string='Internal Note', readonly=True, states={'draft': [('readonly', False)]})
    contract_id = fields.Many2one('hr.contract', string='Contract', readonly=True,
        states={'draft': [('readonly', False)]})
    details_by_salary_rule_category = fields.One2many('hr.payslip.line',
        compute='_compute_details_by_salary_rule_category', string='Details by Salary Rule Category')
    credit_note = fields.Boolean(string='Credit Note', readonly=True,
        states={'draft': [('readonly', False)]},
        help="Indicates this payslip has a refund of another")
    payslip_run_id = fields.Many2one('hr.payslip.run', string='Payslip Batches', readonly=True,
        copy=False, states={'draft': [('readonly', False)]})
    payslip_count = fields.Integer(compute='_compute_payslip_count', string="Payslip Computation Details")
    @api.multi
    def _compute_details_by_salary_rule_category(self):
        for payslip in self:
            payslip.details_by_salary_rule_category = payslip.mapped('line_ids').filtered(lambda line: line.category_id)
    @api.multi
    def _compute_payslip_count(self):
        for payslip in self:
            payslip.payslip_count = len(payslip.line_ids)
    @api.constrains('date_from', 'date_to')
    def _check_dates(self):
        if any(self.filtered(lambda payslip: payslip.date_from > payslip.date_to)):
            raise ValidationError(_("Payslip 'Date From' must be before 'Date To'."))
    @api.multi
    def action_payslip_draft(self):
        return self.write({'state': 'draft'})
    @api.multi
    def action_payslip_done(self):