Files
Odoo-18.0-20251222/maintenance_timesheet_time_control/wizards/hr_timesheet_switch.py
tocmo0nlord adbe430761
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

24 lines
824 B
Python

# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models
class HrTimesheetSwitch(models.TransientModel):
_inherit = "hr.timesheet.switch"
@api.model
def _closest_suggestion(self):
"""Allow to search the best suggestion by maintenance.request."""
result = super()._closest_suggestion()
if not result and self.env.context["active_model"] == "maintenance.request":
return self.env["account.analytic.line"].search(
[
("user_id", "=", self.env.user.id),
("maintenance_request_id", "=", self.env.context["active_id"]),
],
order="date_time DESC",
limit=1,
)
return result