From 8a521c7077205a4c1fb04b6bbc61f396176e3b75 Mon Sep 17 00:00:00 2001 From: David Beal Date: Sun, 18 Aug 2024 18:42:59 +0200 Subject: [PATCH] wip --- .../models/hr_timesheet_sheet.py | 16 +++++++--------- hr_timesheet_quick_add/views/hr_timesheet.xml | 4 ++++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hr_timesheet_quick_add/models/hr_timesheet_sheet.py b/hr_timesheet_quick_add/models/hr_timesheet_sheet.py index 37f206b1b..ef96fb24a 100644 --- a/hr_timesheet_quick_add/models/hr_timesheet_sheet.py +++ b/hr_timesheet_quick_add/models/hr_timesheet_sheet.py @@ -13,6 +13,8 @@ class Hr_TimesheetSheet(models.Model): store=False, compute="_compute_recent_tasks", ) + default_hour = fields.Integer(default=1) + default_name = fields.Char(default="/") @api.depends("timesheet_ids") def _compute_recent_tasks(self): @@ -50,18 +52,14 @@ def _add_timesheet_from_candidates(self, residual_tasks): { "project_id": task.project_id.id, "task_id": task.id, - "unit_amount": self._get_default_unit_amout_from_candidates(), - "name": self._get_default_name_from_candidates(), - "date": fields.Date.today(), + "unit_amount": self.default_hour, + "name": self.default_name, } ) + 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) - def _get_default_name_from_candidates(self): - return "/" - - def _get_default_unit_amout_from_candidates(self): - return 1 - def _get_default_days_history(self): return 20 diff --git a/hr_timesheet_quick_add/views/hr_timesheet.xml b/hr_timesheet_quick_add/views/hr_timesheet.xml index bed2ef9ed..b81238300 100644 --- a/hr_timesheet_quick_add/views/hr_timesheet.xml +++ b/hr_timesheet_quick_add/views/hr_timesheet.xml @@ -16,6 +16,10 @@ colspan="4" >If you remove candidates and save, they'll be populated as real timesheets + + + +