hr_timesheet_sheet* fixes: back to list after remove a timesheet. bulk unfreeze confirmed and pending sheets
This commit is contained in:
parent
8b0d0bb6cc
commit
0323b6672e
11 changed files with 354 additions and 34 deletions
|
|
@ -107,7 +107,46 @@ class HrTimesheetSheetDeleteWizard(models.TransientModel):
|
|||
)
|
||||
return Markup("").join(parts)
|
||||
|
||||
def _delete_cascade_list_action_xml_id(self):
|
||||
"""Hook for extensions
|
||||
|
||||
The list the user plausibly comes from. Deleting the sheet of another
|
||||
employee requires *Timesheets / Administrator*, and that sheet is only
|
||||
listed by *All Timesheet Sheets*; every other case is a user looking at
|
||||
his own sheets, and *My Timesheet Sheets* is the only list of sheets an
|
||||
employee outside that group has a menu for.
|
||||
"""
|
||||
self.ensure_one()
|
||||
own_sheets = self.sheet_ids.user_id == self.env.user
|
||||
is_manager = self.env.user.has_group("hr_timesheet.group_timesheet_manager")
|
||||
if own_sheets or not is_manager:
|
||||
return "hr_timesheet_sheet.act_hr_timesheet_sheet_my_timesheets"
|
||||
return "hr_timesheet_sheet.act_hr_timesheet_sheet_all_timesheets"
|
||||
|
||||
def _delete_cascade_next_action(self):
|
||||
"""Hook for extensions
|
||||
|
||||
Called before the deletion, while the sheets can still be read.
|
||||
|
||||
Opened from a list, the caller is left on that list: closing the dialog
|
||||
reloads it and keeps its filters, its grouping and its selection, and
|
||||
there is no dead record on screen. Opened from the form of a sheet that
|
||||
no longer exists, closing the dialog would leave that form on screen
|
||||
with the values of a deleted record: return the list of sheets instead,
|
||||
with ``target="main"`` so the deleted form is dropped from the
|
||||
breadcrumb rather than kept one step behind.
|
||||
"""
|
||||
self.ensure_one()
|
||||
if not self.env.context.get("sheet_delete_cascade_from_form"):
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
action = self.env["ir.actions.act_window"]._for_xml_id(
|
||||
self._delete_cascade_list_action_xml_id()
|
||||
)
|
||||
action["target"] = "main"
|
||||
return action
|
||||
|
||||
def action_confirm_delete(self):
|
||||
self.ensure_one()
|
||||
next_action = self._delete_cascade_next_action()
|
||||
self.sheet_ids._with_delete_cascade().unlink()
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
return next_action
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue