Skip to content

Commit

Permalink
[FIX] hr_work_entry_contract: compute duration without employee
Browse files Browse the repository at this point in the history
This traceback arises when the user changes the 'end_date' without the employee
value, while creating a new 'Work Entry'.

To reproduce this issue:

1) Install 'hr_work_entry_contract'
2) Open 'payroll' and create a new 'Work Entry'
3) Select 'Work Entry Type' as 'Unpaid' and change the 'To' date

Error:- 'KeyError: False'

On the '_get_duration_batch' method, when the user is not given employee value,
there will be no 'contract_id' as it is getting value from 'employee_id'.

It leads to the above traceback as 'result[work_entry.id]' is getting value
through 'employee.id'.

See:- https://github.com/odoo/odoo/blob/a277faa2ffab7559fcbad95fcc1e8fd6a26d756b/addons/hr_work_entry_contract/models/hr_work_entry.py#L110-L112

Will resolve this issue by calculating duration without employee

sentry-4514970596

closes odoo#138033

X-original-commit: cc3898a
Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
  • Loading branch information
alsh-odoo committed Oct 10, 2023
1 parent 5883843 commit 74801ad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion addons/hr_work_entry_contract/models/hr_work_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def _get_duration_batch(self):
# {(date_start, date_stop): {calendar: employees}}
mapped_periods = defaultdict(lambda: defaultdict(lambda: self.env['hr.employee']))
for work_entry in self:
if not work_entry.date_start or not work_entry.date_stop or not work_entry._is_duration_computed_from_calendar():
if not work_entry.date_start or not work_entry.date_stop or not work_entry._is_duration_computed_from_calendar() or not work_entry.employee_id:
super_work_entries |= work_entry
continue
date_start = work_entry.date_start
Expand Down

0 comments on commit 74801ad

Please sign in to comment.