diff --git a/hr_timesheet_quick_add/README.rst b/hr_timesheet_quick_add/README.rst index 3fabd98f8..a19af8b3a 100644 --- a/hr_timesheet_quick_add/README.rst +++ b/hr_timesheet_quick_add/README.rst @@ -28,7 +28,7 @@ HR Timesheet Quick Add |badge1| |badge2| |badge3| |badge4| |badge5| -Add a field to select task among last used timesheet ones +Add a field to select tasks among last used timesheet ones Here is `Timesheet candidates` field display tasks on which you recorded time recently. @@ -37,6 +37,9 @@ Here is `Timesheet candidates` field display tasks on which you recorded time re .. figure:: https://raw.githubusercontent.com/OCA/timesheet/16.0/hr_timesheet_quick_add/static/description/im1.png :alt: Timesheet candidates field + +This module is especially useful when your week timesheet is empty and you have worked on same tasks than previous week. + **Table of contents** .. contents:: diff --git a/hr_timesheet_quick_add/models/hr_timesheet_sheet.py b/hr_timesheet_quick_add/models/hr_timesheet_sheet.py index 9d5b0a1df..62112f5eb 100644 --- a/hr_timesheet_quick_add/models/hr_timesheet_sheet.py +++ b/hr_timesheet_quick_add/models/hr_timesheet_sheet.py @@ -12,9 +12,12 @@ class Hr_TimesheetSheet(models.Model): readonly=False, store=False, compute="_compute_recent_tasks", + help="Tasks candidates to timesheet", + ) + default_hour = fields.Integer(string="Hours", default=1, help="Default hours") + default_description = fields.Char( + string="Description", default="/", help="Default description" ) - default_hour = fields.Integer(default=1) - default_name = fields.Char(default="/") @api.depends("timesheet_ids") def _compute_recent_tasks(self): @@ -40,28 +43,30 @@ def write(self, vals): "candidate_task_ids" in vals and vals["candidate_task_ids"][0][2] ) for rec in self: - if residual_tasks or rec.candidate_task_ids: + if "candidate_task_ids" in vals: rec._add_timesheet_from_candidates(residual_tasks) + vals["name"] = "/" return super().write(vals) def _add_timesheet_from_candidates(self, residual_tasks): self.ensure_one() + residual_tasks = residual_tasks or [] task_ids = [x for x in self.candidate_task_ids.ids if x not in residual_tasks] values = self._prepare_empty_analytic_line() for task in self.env["project.task"].browse(task_ids): - vals = values.copy() - vals.update( + tvals = values.copy() + tvals.update( { "project_id": task.project_id.id, "task_id": task.id, "unit_amount": self.default_hour, - "name": self.default_name or "/", + "name": self.default_description or "/", } ) date = fields.Date.today() if date >= self.date_start and date <= self.date_end: - vals["date"] = date - self.timesheet_ids |= self.env["account.analytic.line"]._sheet_create(vals) + tvals["date"] = date + self.timesheet_ids |= self.env["account.analytic.line"]._sheet_create(tvals) def _get_default_days_history(self): return 20 diff --git a/hr_timesheet_quick_add/readme/DESCRIPTION.rst b/hr_timesheet_quick_add/readme/DESCRIPTION.rst index e996d78ea..08cef6abb 100644 --- a/hr_timesheet_quick_add/readme/DESCRIPTION.rst +++ b/hr_timesheet_quick_add/readme/DESCRIPTION.rst @@ -1,4 +1,4 @@ -Add a field to select task among last used timesheet ones +Add a field to select tasks among last used timesheet ones Here is `Timesheet candidates` field display tasks on which you recorded time recently. @@ -6,3 +6,6 @@ Here is `Timesheet candidates` field display tasks on which you recorded time re .. figure:: ../static/description/im1.png :alt: Timesheet candidates field + + +This module is especially useful when your week timesheet is empty and you have worked on same tasks than previous week. diff --git a/hr_timesheet_quick_add/static/description/index.html b/hr_timesheet_quick_add/static/description/index.html index 38dd4f161..22830458a 100644 --- a/hr_timesheet_quick_add/static/description/index.html +++ b/hr_timesheet_quick_add/static/description/index.html @@ -369,11 +369,12 @@
Add a field to select task among last used timesheet ones
+Add a field to select tasks among last used timesheet ones
Here is Timesheet candidates field display tasks on which you recorded time recently.
This module is especially useful when your week timesheet is empty and you have worked on same tasks than previous week.
Table of contents
If you remove these candidates and save, they'll be populated as real timesheets with 'Hours' and 'Description'