Sarah Bellefroid c07a0d2193 [FIX] hr_holidays: compute allocation name for manager
Currently when a manager goes to validate an allocation, the name/description of the allocation is not displayed. This introduces the need for manager to name each allocation manually to be able to validate them.

Steps to reproduce:
-------------------
* Open **Time off** app
* On the dashboard, select **New allocation Request**
* Save the allocation as it is
* Select **Management** > **Allocations**
  > Observation : The description field of the new allocation is not filled.
* Select the new allocation
* Validate
  > Observation: Unable to validate, description field required.

Why the fix:
------------
The description of an allocation corresponds to the field `name` in the model `hr_leave_allocation`.

https://github.com/odoo/odoo/blob/e2ad568e6cd4de2d721149eb76d04f58c8510191/addons/hr_holidays/models/hr_leave_allocation.py#L40-L45

In the compute method of this field, the name gets actualy computed in the context of `is_employee_allocation`.

https://github.com/odoo/odoo/blob/e2ad568e6cd4de2d721149eb76d04f58c8510191/addons/hr_holidays/models/hr_leave_allocation.py#L169-L177

We are in the context `is_employee_allocation` either by asking a new allocation from the dashboard, either by being on the `hr_leave_allocation_action_my` view.

https://github.com/odoo/odoo/blob/2bcccbfb910609f6cf54d607d198aae4c5b28b86/addons/hr_holidays/static/src/views/hooks.js#L62-L65

https://github.com/odoo/odoo/blob/2bcccbfb910609f6cf54d607d198aae4c5b28b86/addons/hr_holidays/views/hr_leave_allocation_views.xml#L456

On those two views, the description is computed and readonly. Since the name is readonly, it means that the inverse of the compute method will not get called, thus never setting `private_name`.

https://github.com/odoo/odoo/blob/2bcccbfb910609f6cf54d607d198aae4c5b28b86/addons/hr_holidays/models/hr_leave_allocation.py#L182-L186

When a manager goes to approve an allocation, he goes through **Management** > **Allocations**. The views used are either `hr_leave_allocation_view_tree` or `hr_leave_allocation_view_form_manager`. On those views, we are not in the context `is_employee_id`, the allocation name is no more readonly and the name is required in order to validate the allocation.

For a manager to be able to see anything in the description, the field `private_name` must be set.

https://github.com/odoo/odoo/blob/2bcccbfb910609f6cf54d607d198aae4c5b28b86/addons/hr_holidays/models/hr_leave_allocation.py#L164-L178

This fix aims to create consistency in the creation of allocations. We can observe that the name is not in `vals` in the `web_save` function when creating an allocation through the dashboard or the tab **My Time** > **My allocations**. However, when creating an allocation through **Management** > **Allocations**, name can be found in `vals`.

https://github.com/odoo/odoo/blob/764088d6d5a5a18be451ec26b886691718bef835/addons/web/models/models.py#L69C5-L69C75

`vals` corresponds to `changes` in this function:

https://github.com/odoo/odoo/blob/764088d6d5a5a18be451ec26b886691718bef835/addons/web/static/src/model/relational_model/record.js#L1045-L1051

To have the name added to `changes`, we ultimately need the following condition to be false.

https://github.com/odoo/odoo/blob/764088d6d5a5a18be451ec26b886691718bef835/addons/web/static/src/model/relational_model/record.js#L592-L599

In the manager flow, this is the case as `name` is not readonly. As a regular employee, the only possible way to hae this false while keeping the `name` readonly, is to make it an active field.

`name` in now in `vals` and thus in `vals_list` in the create method. This will thus allow to set `private_name` through the inverse function of name.

opw-3722093

closes odoo/odoo#155767

Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
2024-03-15 13:04:46 +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%