跳至内容
菜单
此问题已终结

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

形象
丢弃

Hi Ricardo Gross,

You can add logic in create method of timesheet.

最佳答案

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.")




形象
丢弃
相关帖文 回复 查看 活动
5
1月 25
4582
0
2月 23
2132
3
10月 23
2630
2
2月 25
3447
1
8月 23
2527