Skip to content
Snippets Groups Projects
Commit 9413222e authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[FIX] hr_holidays: allocation multi-company


As Mitchell Admin:
- Install Leaves
- General Settings > Multi Company
- Create companies A (YourCompany) and B
- Mitchell Admin should be an employee of A, not B
- Switch to company B
- Go to Leaves > Managers > All > Allocations

An AccessError is raised in `_compute_number_of_hours_display` because
we try to access `employee_id.resource_calendar_id.hours_per_day`.

After this AccessError is solved, several others are raised when
accessing a record. They are solved in this commit.

opw-2160542

closes odoo/odoo#43485

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent d077b224
Branches
Tags
No related merge requests found
......@@ -209,7 +209,7 @@ class HolidaysAllocation(models.Model):
if allocation.parent_id and allocation.parent_id.type_request_unit == "hour":
allocation.number_of_hours_display = allocation.number_of_days * HOURS_PER_DAY
else:
allocation.number_of_hours_display = allocation.number_of_days * (allocation.employee_id.resource_calendar_id.hours_per_day or HOURS_PER_DAY)
allocation.number_of_hours_display = allocation.number_of_days * (allocation.employee_id.sudo().resource_calendar_id.hours_per_day or HOURS_PER_DAY)
@api.multi
@api.depends('number_of_hours_display', 'number_of_days_display')
......@@ -320,12 +320,12 @@ class HolidaysAllocation(models.Model):
elif allocation.holiday_type == 'category':
target = allocation.category_id.name
else:
target = allocation.employee_id.name
target = allocation.employee_id.sudo().name
res.append(
(allocation.id,
_("Allocation of %s : %.2f %s to %s") %
(allocation.holiday_status_id.name,
(allocation.holiday_status_id.sudo().name,
allocation.number_of_hours_display if allocation.type_request_unit == 'hour' else allocation.number_of_days,
_('hours') if allocation.type_request_unit == 'hour' else _('days'),
target))
......@@ -506,7 +506,7 @@ class HolidaysAllocation(models.Model):
is_officer = self.env.user.has_group('hr_holidays.group_hr_holidays_user')
is_manager = self.env.user.has_group('hr_holidays.group_hr_holidays_manager')
for holiday in self:
val_type = holiday.holiday_status_id.validation_type
val_type = holiday.holiday_status_id.sudo().validation_type
if state == 'confirm':
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment