feat(project_management): add estimation field to project api fields

ref: #722 closes #312
This commit is contained in:
2025-04-15 16:41:34 +09:30
parent 75618de977
commit a0d750b1f5
2 changed files with 30 additions and 0 deletions

View File

@ -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.

View File

@ -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',