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
|
|
@ -4,6 +4,7 @@
|
|||
import logging
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.osv import expression
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -17,14 +18,24 @@ class HrTimesheetSheet(models.Model):
|
|||
return [("state", "in", ("confirm", "done"))]
|
||||
|
||||
@api.model
|
||||
def _unfreeze_sheets(self):
|
||||
def _unfreeze_sheets(self, sheets=None):
|
||||
"""Send frozen sheets back to draft. Returns the number of sheets affected.
|
||||
|
||||
Without ``sheets``, every frozen sheet the current user can see is
|
||||
released, which is the historical behaviour of this hook. With
|
||||
``sheets``, only those of them that are still frozen are released: the
|
||||
wizard passes the recordset it showed the user, so the confirmation
|
||||
message counts what the warning announced and not what the database
|
||||
happens to hold by the time the button is pressed.
|
||||
|
||||
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())
|
||||
domain = self._unfreeze_domain()
|
||||
if sheets is not None:
|
||||
domain = expression.AND([domain, [("id", "in", sheets.ids)]])
|
||||
sheets = self.search(domain)
|
||||
if not sheets:
|
||||
_logger.info("No frozen timesheet sheets to unfreeze.")
|
||||
return 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue