feat(project_management): add estimation field to project api fields
ref: #722 closes #312
This commit is contained in:
@ -200,6 +200,7 @@ class Project(ProjectCommonFieldsName):
|
||||
'priority',
|
||||
],
|
||||
"right": [
|
||||
'estimation_project',
|
||||
'duration_project',
|
||||
]
|
||||
},
|
||||
@ -317,6 +318,32 @@ class Project(ProjectCommonFieldsName):
|
||||
return int(duration_project)
|
||||
|
||||
|
||||
@property
|
||||
def estimation_project(self) -> int:
|
||||
|
||||
estimation_project: int = 0
|
||||
|
||||
from core.models.ticket.ticket import Ticket
|
||||
|
||||
tickets = Ticket.objects.filter(
|
||||
project = self.id
|
||||
)
|
||||
|
||||
for ticket in tickets:
|
||||
|
||||
estimation = ticket.estimate
|
||||
|
||||
if ticket.estimate is None:
|
||||
|
||||
estimation = 0
|
||||
|
||||
|
||||
estimation_project = estimation_project + int(estimation)
|
||||
|
||||
|
||||
return int(estimation_project)
|
||||
|
||||
|
||||
@property
|
||||
def percent_completed(self) -> str: # Auto-Calculate
|
||||
""" How much of the project is completed.
|
||||
|
@ -90,6 +90,7 @@ class ProjectModelSerializer(
|
||||
'description',
|
||||
'priority',
|
||||
'state',
|
||||
'estimation_project',
|
||||
'duration_project',
|
||||
'completed',
|
||||
'project_type',
|
||||
@ -110,6 +111,8 @@ class ProjectModelSerializer(
|
||||
|
||||
read_only_fields = [
|
||||
'id',
|
||||
'estimation_project',
|
||||
'duration_project',
|
||||
'completed',
|
||||
'display_name',
|
||||
'external_ref',
|
||||
|
Reference in New Issue
Block a user