|
@@ -14,7 +14,15 @@ class ProjectTask(models.Model):
|
|
|
def compute_days_duration(self):
|
|
def compute_days_duration(self):
|
|
|
for rec in self:
|
|
for rec in self:
|
|
|
if rec.x_start_date and rec.x_end_date:
|
|
if rec.x_start_date and rec.x_end_date:
|
|
|
- rec.x_days_duration = (rec.x_end_date - rec.x_start_date).days
|
|
|
|
|
|
|
+ days = (rec.x_end_date - rec.x_start_date).days
|
|
|
|
|
+ day_date = rec.x_start_date
|
|
|
|
|
+ duration = 0
|
|
|
|
|
+ for day in range(days + 1):
|
|
|
|
|
+ weekday = day_date.weekday()
|
|
|
|
|
+ if weekday not in [5,6]:
|
|
|
|
|
+ duration += 1
|
|
|
|
|
+ day_date += timedelta(days=1)
|
|
|
|
|
+ rec.x_days_duration = duration
|
|
|
else:
|
|
else:
|
|
|
rec.x_days_duration = 0
|
|
rec.x_days_duration = 0
|
|
|
|
|
|