Merge pull request #5810 from expsa/khazraji_project

fix
This commit is contained in:
mohammed-alkhazrji 2025-12-24 14:12:31 +03:00 committed by GitHub
commit 990dcdd8f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 4 deletions

View File

@ -136,14 +136,21 @@ class ProjectPhase(models.Model):
progress = ((sum([x.weight * x.task_progress for x in done_task])) / 100)
# progress = round(100.0 * float((len(done_task) / len(rec.task_ids))), 2)
rec.progress = progress
@api.constrains('start_date', 'end_date')
def _check_dates(self):
for rec in self:
if rec.filtered(lambda c: c.end_date and c.start_date > c.end_date):
if rec.start_date and rec.end_date and rec.start_date > rec.end_date:
raise ValidationError(_('Phase start date must be earlier than Phase end date.'))
if rec.project_id.start and rec.project_id.date and (rec.start_date < rec.project_id.start or rec.start_date > rec.project_id.date) or \
(rec.end_date < rec.project_id.start or rec.end_date > rec.project_id.date):
project = rec.project_id
if not project.start or not project.date:
continue
if rec.start_date and (rec.start_date < project.start or rec.start_date > project.date):
raise ValidationError(_('Phase dates must be between project dates.'))
if rec.end_date and (rec.end_date < project.start or rec.end_date > project.date):
raise ValidationError(_('Phase dates must be between project dates.'))
def action_draft(self):