[ADD] PMS: Added new field duration unit for objectives, and employeeobjective end date calculation based on the duration unit
This commit is contained in:
@@ -116,9 +116,10 @@ class ObjectiveForm(BaseForm):
|
||||
fields = [
|
||||
"title",
|
||||
"managers",
|
||||
"description",
|
||||
"duration_unit",
|
||||
"duration",
|
||||
"key_result_id",
|
||||
"description",
|
||||
"add_assignees",
|
||||
"assignees",
|
||||
"start_date",
|
||||
|
||||
@@ -73,6 +73,11 @@ class KeyResult(HorillaModel):
|
||||
class Objective(HorillaModel):
|
||||
"""Model used for creating objectives"""
|
||||
|
||||
DURATION_UNIT = (
|
||||
("days", _("Days")),
|
||||
("months", _("Months")),
|
||||
("years", _("Years")),
|
||||
)
|
||||
title = models.CharField(
|
||||
null=False, blank=False, max_length=100, verbose_name="Title"
|
||||
)
|
||||
@@ -94,6 +99,14 @@ class Objective(HorillaModel):
|
||||
related_name="objective",
|
||||
verbose_name="Default Key results",
|
||||
)
|
||||
duration_unit = models.CharField(
|
||||
max_length=20,
|
||||
choices=DURATION_UNIT,
|
||||
null=True,
|
||||
blank=True,
|
||||
default="days",
|
||||
verbose_name="Duration Unit",
|
||||
)
|
||||
duration = models.IntegerField(default=1, validators=[MinValueValidator(0)])
|
||||
add_assignees = models.BooleanField(default=False)
|
||||
archive = models.BooleanField(default=False, null=True, blank=True)
|
||||
@@ -199,7 +212,12 @@ class EmployeeObjective(HorillaModel):
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.pk and self.objective_id and self.start_date:
|
||||
duration = self.objective_id.duration
|
||||
self.end_date = self.start_date + relativedelta(days=duration)
|
||||
if self.objective_id.duration_unit == "days":
|
||||
self.end_date = self.start_date + relativedelta(days=duration)
|
||||
elif self.objective_id.duration_unit == "months":
|
||||
self.end_date = self.start_date + relativedelta(months=duration)
|
||||
elif self.objective_id.duration_unit == "years":
|
||||
self.end_date = self.start_date + relativedelta(years=duration)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def tracking(self):
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
</li>
|
||||
<li class="helpdesk__card-item">
|
||||
<span class="helpdesk__card-label">{% trans "Duration:" %}</span>
|
||||
<span class="helpdesk__card-value" name="" id="">{{objective.duration}} {% trans "days" %}</span>
|
||||
<span class="helpdesk__card-value" name="" id="">{{objective.duration}} {{objective.get_duration_unit_display}}</span>
|
||||
</li>
|
||||
<li class="helpdesk__card-item">
|
||||
<span class="helpdesk__card-label">{% trans "Description:" %}</span>
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
<span class="count-span">{{ objective.employee_objective.all|length}} {% trans "Assignees" %}</span>
|
||||
</div>
|
||||
<div data-cell-index="4" class="oh-sticky-table__td ">
|
||||
{{objective.duration}}
|
||||
{{objective.duration}} {{objective.get_duration_unit_display}}
|
||||
</div>
|
||||
<div data-cell-index="5" class="oh-sticky-table__td">
|
||||
{{objective.description}}
|
||||
|
||||
Reference in New Issue
Block a user