add hr_timesheet_sheet_no_review, hr_timesheet_sheet_holidays, hr_timesheet_sheet_delete_cascade

This commit is contained in:
Luis 2026-09-22 10:58:36 +02:00
parent b07082f70d
commit 8b0d0bb6cc
53 changed files with 3953 additions and 0 deletions

View file

@ -0,0 +1,48 @@
# Copyright 2026 Criptomart
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import logging
from odoo import api, models
_logger = logging.getLogger(__name__)
class HrTimesheetSheet(models.Model):
_inherit = "hr_timesheet.sheet"
@api.model
def _unfreeze_domain(self):
"""Hook for extensions: which sheets are considered frozen."""
return [("state", "in", ("confirm", "done"))]
@api.model
def _unfreeze_sheets(self):
"""Send frozen sheets back to draft. Returns the number of sheets affected.
The update is issued in SQL on purpose: going through ``write()`` would
trigger the sheet recomputation and one tracking message per sheet, on a
volume that is measured in thousands of records.
"""
sheets = self.search(self._unfreeze_domain())
if not sheets:
_logger.info("No frozen timesheet sheets to unfreeze.")
return 0
sheets.check_access_rights("write")
sheets.check_access_rule("write")
self.env.flush_all()
self.env.cr.execute(
"""
UPDATE hr_timesheet_sheet
SET state = 'draft',
reviewer_id = NULL,
write_uid = %s,
write_date = (now() at time zone 'UTC')
WHERE id IN %s
""",
(self.env.uid, tuple(sheets.ids)),
)
count = self.env.cr.rowcount
self.env.invalidate_all(flush=False)
_logger.info("Unfroze %s timesheet sheet(s).", count)
return count