Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
1
maintenance_timesheet_time_control/wizards/__init__.py
Normal file
1
maintenance_timesheet_time_control/wizards/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import hr_timesheet_switch
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user