diff --git a/addons/hr_work_entry_contract/models/hr_employee.py b/addons/hr_work_entry_contract/models/hr_employee.py index 05e8edc7fb7..235c6e6317b 100644 --- a/addons/hr_work_entry_contract/models/hr_employee.py +++ b/addons/hr_work_entry_contract/models/hr_employee.py @@ -1,6 +1,7 @@ # -*- coding:utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from collections import defaultdict from odoo import fields, models @@ -17,4 +18,12 @@ class HrEmployee(models.Model): else: current_contracts = self._get_all_contracts(date_start, date_stop, states=['open', 'close']) - return bool(current_contracts._generate_work_entries(date_start, date_stop, force)) + new_work_entries = False + contracts_by_company = defaultdict(lambda: self.env['hr.contract']) + for contract in current_contracts: + contracts_by_company[contract.company_id] |= contract + + for company, contracts in contracts_by_company.items(): + new_work_entries = bool(contracts.with_company(company)._generate_work_entries( + date_start, date_stop, force)) or new_work_entries + return new_work_entries