[FIX] hr_work_entry_contract: Fix multi-company work entries generation
closes odoo/odoo#99760 X-original-commit: f32cb46f18a5ea28b39b29c3c7934656d6af72a0 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user