created if cases for changing of year for projects that were already there, but already have a project_of_year number
This commit is contained in:
parent
c113e37b3f
commit
7c05040d7b
1 changed files with 28 additions and 5 deletions
|
@ -104,9 +104,20 @@ class Project(Volunteer):
|
|||
'''we generate the autogenerated fields here'''
|
||||
# we don't call save with args/kwargs to avoid UNIQUE CONSTRAINT errors
|
||||
# but maybe there is a better solution?
|
||||
startyear_tmp = 'NONE'
|
||||
|
||||
if self.pid:
|
||||
if self.pid[:4] != self.start.year:
|
||||
startyear_tmp = self.start.year
|
||||
|
||||
super().save()
|
||||
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
|
||||
# self.pid = str(self.account.code) + str(self.pk).zfill(3)
|
||||
|
||||
if startyear_tmp == 'NONE':
|
||||
|
||||
self.pid = str(self.start.year) + '-' + str(self.account.code) + str(self.pk).zfill(3)
|
||||
# self.pid = str(self.account.code) + str(self.pk).zfill(3)
|
||||
|
||||
|
||||
|
||||
# generation of field quartals
|
||||
if self.end.month in [1, 2, 3]:
|
||||
|
@ -119,13 +130,25 @@ class Project(Volunteer):
|
|||
self.end_quartal = 'Q4'
|
||||
|
||||
# generation of pid and financeID
|
||||
# project of year is true if entry gets updated with changes.. but year can change!!!!!!!!
|
||||
if self.project_of_year:
|
||||
print('oi oi oi oi oi')
|
||||
print(self.pid)
|
||||
|
||||
|
||||
|
||||
|
||||
# project of year is false if entry gets saved as new
|
||||
if not self.project_of_year or startyear_tmp != 'NONE':
|
||||
print('AAA')
|
||||
|
||||
print('self projekt of year', self.project_of_year, self.start.year)
|
||||
|
||||
if not self.project_of_year:
|
||||
#print('AAA')
|
||||
# we need to determine if this is a new year with its first new project...
|
||||
year = self.start.year
|
||||
#print(year)
|
||||
projects = Project.objects.filter(start__year=year)
|
||||
print('projects after filter of startyear of project',projects)
|
||||
if not projects:
|
||||
#print('BBB')
|
||||
self.project_of_year = 1
|
||||
|
|
Loading…
Reference in a new issue