Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata

A folded stage is defined as: "If enabled, this stage will be displayed as folded in the Kanban view of your projects/tasks. Projects/Tasks in a folded stage are considered as closed"

As it's not possible to configure the timesheet app so that projects and/or tasks in a folded stage are no longer available for timesheeting, is there a workaround or maybe a automated action/ automation to raise a UserError when users try to register hours in "closed" /project/tasks?

Thanks

Avatar
Abbandona

Hi Ricardo Gross,

You can add logic in create method of timesheet.

Risposta migliore

Hi Ricardo, I have created an automated action that checks timesheet registration based on the start and end date of the task. I think you could change part of the code. Our problem is that our consutlants shouldn't be able to write time for dates outside the start:end date of a taks. Even when e.g. the project manager hasn't put the task in a folded stage. 

  • The timesheet_datetime_start is set to the start of the day (00:00:00) of the timesheet entry's date.
  • The timesheet_datetime_end is set to the end of the day (23:59:59) of the timesheet entry's date.
  • These datetime objects are then used for comparison with the task's planned start and end dates.



Here's the code:


task = record.task_id

timesheet_date = record.date  # or 'date_time', depending on your setup


if task and task.planned_date_begin and task.planned_date_end:

     # Convert timesheet_date to datetime for comparison

    timesheet_datetime_start = datetime.datetime(timesheet_date.year, timesheet_date.month, timesheet_date.day)

    timesheet_datetime_end = datetime.datetime(timesheet_date.year, timesheet_date.month, timesheet_date.day, 23, 59, 59)

  

    if not (task.planned_date_begin <= timesheet_datetime_start <= task.planned_date_end or

            task.planned_date_begin <= timesheet_datetime_end <= task.planned_date_end):

        raise UserError("You cannot log time outside the task's scheduled dates.")




Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
5
gen 25
4580
0
feb 23
2129
3
ott 23
2626
2
feb 25
3445
1
ago 23
2525