diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-01-17 12:32:13 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-01-20 08:09:08 +0000 |
| commit | f211eaafcba64bf51a036218d6d6ebbf0864ab6b (patch) | |
| tree | 1e5246c2132b66e445564daec5ca9da7e8a5097f | |
| parent | c6dff462035feb4d949a646c05ae4e2e8092c224 (diff) | |
[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#43529
X-original-commit: 97085bf16e009ea563719385c8c7073436a1aa7e
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | addons/hr_holidays/models/hr_leave_allocation.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/addons/hr_holidays/models/hr_leave_allocation.py b/addons/hr_holidays/models/hr_leave_allocation.py index b9faa215553..9e24ba844ea 100644 --- a/addons/hr_holidays/models/hr_leave_allocation.py +++ b/addons/hr_holidays/models/hr_leave_allocation.py @@ -257,7 +257,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.depends('number_of_hours_display', 'number_of_days_display') def _compute_duration_display(self): @@ -366,12 +366,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)) @@ -547,7 +547,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.allocation_validation_type + val_type = holiday.holiday_status_id.sudo().allocation_validation_type if state == 'confirm': continue |
