From 485dc5cdc5211bd2465fb1aea481c451fe666cd3 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Thu, 24 Mar 2022 16:39:02 +0100 Subject: [PATCH] use older timesheet dates --- organization/network/admin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/organization/network/admin.py b/organization/network/admin.py index 6fdcf142..d7689a80 100644 --- a/organization/network/admin.py +++ b/organization/network/admin.py @@ -540,6 +540,15 @@ def copy_activity_timesheets(self, request, queryset): work_packages = timesheet.work_packages.all() timesheet.id = None timesheet.month = month + last_other_timesheets = PersonActivityTimeSheet.objects.filter( + activity=timesheet.activity, + year=timesheet.year, + month=timesheet.month).order_by('-validation') + + if last_other_timesheets: + timesheet.accounting = last_other_timesheets[0].accounting + timesheet.validation = last_other_timesheets[0].validation + timesheet.save() for work_package in work_packages: timesheet.work_packages.add(work_package)