Xavier Bol (xbo) 0b6e8e3b00 [FIX] hr_timesheet: get company of the employee without potential issue
Before this commit, when the current user did not have
`hr.group_hr_user` group and creates a timesheet for an employee in his
team, he could get a traceback before one field defined only
`hr.employee` model cannot be fetched in `hr.employee.public` by the
ORM. The reason is because when the user creates a timesheet in a task
without any company set, we will take the company of the employee set
on the timesheet to set it in the new timesheet, by doing that, the ORM
will prefetch the fields of `hr.employee` and returned the company from
its cache.

This commit makes sure we will not have any issue when we try to get the
company of the employee to set in the new timesheet if one field defined
in `hr.employee` is not defined in `hr.employee.public` and has to be
prefetched by the ORM.

Steps to reproduce (in 17+)
==================
0. install `hr_timesheet` and `pos_blackbox_be` modules.
1. create a user A with `hr_timesheet.group_hr_timesheet_approver`,
   without any access to Employee app
2. create a project and a task without any company set (default value)
3. log in as user A
4. go to the form view of task created in step 2
5. add a timesheet and save the form view

Expected Behavior
=================
The timesheet should be added in the task and the form view should be
saved without any issue.

Actual Behavior
===============
A traceback is occured saying "The fields 'insz_or_bis_number' you try
to read is not available on the public employee profile"

opw-3769277

closes odoo/odoo#158111

X-original-commit: 6022e9fc7b8d58d88994c89cee1471475da4f011
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2024-03-20 21:44:01 +00:00
…
…
…
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%