Skip to content

Commit

Permalink
[FIX] project_timesheet_holidays: enable selection of project in time…
Browse files Browse the repository at this point in the history
… off type

Curently when trying to select an existing/newly created project in the timesheet section of time off types, it will not recognise that the project exists and will suggest to create it.

Steps to reproduce:
-------------------
* Go to **Setting** -> Enable timesheets
* Go to **Time Off** App -> Configuration -> Time off types
* Create new type
* Go to **Project** App
* Create a new project
* Go back to the configuration of the new time off type
* Enable **developer mode**
* Under timesheet section, select project
* Try selection the new project created
* It suggests to create the project/does not recognise it is already created.

Why the fix:
------------
In multi-company this issue can be handled by going into the settings of the project and selecting the same company as the one in the time off type.

This issue is more problematic in case of single company because the field `company_id` is not available in neither the project form nor the time of type. As of currently, the `company_id` on time off type is by default the current company, while it is `False` by default for the project.

This PR introduced that behavior: odoo@16a07ed

Since the `company_id` can now also be `False`, it makes sense to enlarge the filter domain on the time off type form. With that in place, the field `timesheet_task_id` also requires changes because a task created in a project with no `company_id` will not have a `company_id`.

opw-3644265

closes odoo#149620

X-original-commit: 57d5cf3
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
Signed-off-by: Sarah Bellefroid (sbel) <sbel@odoo.com>
  • Loading branch information
sbel-odoo committed Jan 17, 2024
1 parent ac398e4 commit 0b70520
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/project_timesheet_holidays/models/hr_holidays.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class HolidaysType(models.Model):
timesheet_generate = fields.Boolean(
'Generate Timesheets', compute='_compute_timesheet_generate', store=True, readonly=False,
help="If checked, when validating a time off, timesheet will be generated in the Vacation Project of the company.")
timesheet_project_id = fields.Many2one('project.project', string="Project", domain="[('company_id', '=', company_id)]",
timesheet_project_id = fields.Many2one('project.project', string="Project", domain="[('company_id', 'in', [False, company_id])]",
compute="_compute_timesheet_project_id", store=True, readonly=False)
timesheet_task_id = fields.Many2one(
'project.task', string="Task", compute='_compute_timesheet_task_id',
store=True, readonly=False,
domain="[('project_id', '=', timesheet_project_id),"
"('project_id', '!=', False),"
"('company_id', '=', company_id)]")
"('company_id', 'in', [False, company_id])]")

@api.depends('timesheet_task_id', 'timesheet_project_id')
def _compute_timesheet_generate(self):
Expand Down

0 comments on commit 0b70520

Please sign in to comment.