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)



default='''
                    # Available variables:
                    #----------------------
                    # payslip: object containing the payslips
                    # employee: hr.employee object
                    # contract: hr.contract object
                    # rules: object containing the rules code (previously computed)
                    # categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category).
                    # worked_days: object containing the computed worked days.
                    # inputs: object containing the computed inputs.
                    # Note: returned value have to be set in the variable 'result'
                    result = contract.wage * 0.10''')
    amount_percentage_base = fields.Char(string='Percentage based on', help='result will be affected to a variable')
    child_ids = fields.One2many('hr.salary.rule', 'parent_rule_id', string='Child Salary Rule', copy=True)
    register_id = fields.Many2one('hr.contribution.register', string='Contribution Register',
        help="Eventual third party involved in the salary payment of the employees.")
    input_ids = fields.One2many('hr.rule.input', 'input_id', string='Inputs', copy=True)
    note = fields.Text(string='Description')
    @api.multi
    def _recursive_search_of_rules(self):
        """
        @return: returns a list of tuple (id, sequence) which are all the children of the passed rule_ids
        """
        children_rules = []
        for rule in self.filtered(lambda rule: rule.child_ids):
            children_rules += rule.child_ids._recursive_search_of_rules()
        return [(rule.id, rule.sequence) for rule in self] + children_rules
    #T
    @api.multi
    def compute_rule(self, localdict):