Use TimeDelta field
issue4026 review12851002
This commit is contained in:
1 parent
c1e87257ca
commit
7e6156427a
3 files changed
+17
-7
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Use TimeDelta field
|
||||
|
||||
Version 3.4.0 - 2014-10-20
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<label name="actual_finish_date"/>
|
||||
<field name="actual_finish_date"/>
|
||||
<label name="duration"/>
|
||||
<field name="duration" widget="float_time" float_time="company_work_time"/>
|
||||
<field name="duration"/>
|
||||
<newline/>
|
||||
<field name="predecessors" colspan="2"/>
|
||||
<field name="successors" colspan="2"/>
|
||||
|
||||
@@ -40,7 +40,9 @@ class Work:
|
||||
states={
|
||||
'invisible': Eval('type') != 'task',
|
||||
}, depends=['type'])
|
||||
duration = fields.Function(fields.Float('Duration'), 'get_function_fields')
|
||||
duration = fields.Function(
|
||||
fields.TimeDelta('Duration', 'company_work_time'),
|
||||
'get_function_fields')
|
||||
early_start_time = fields.DateTime("Early Start Time", readonly=True)
|
||||
late_start_time = fields.DateTime("Late Start Time", readonly=True)
|
||||
early_finish_time = fields.DateTime("Early Finish Time", readonly=True)
|
||||
@@ -108,12 +110,12 @@ class Work:
|
||||
leafs.add(work.id)
|
||||
|
||||
total_allocation = 0
|
||||
if not work.allocations:
|
||||
durations[work.id] = (work.effort or 0)
|
||||
if not work.allocations or not work.effort_duration:
|
||||
durations[work.id] = work.effort_duration
|
||||
continue
|
||||
for allocation in work.allocations:
|
||||
total_allocation += allocation.percentage
|
||||
durations[work.id] = ((work.effort or 0)
|
||||
durations[work.id] = (work.effort_duration
|
||||
/ (total_allocation / 100.0))
|
||||
|
||||
while leafs:
|
||||
@@ -168,6 +170,12 @@ class Work:
|
||||
})
|
||||
break
|
||||
|
||||
@property
|
||||
def hours(self):
|
||||
if not self.duration:
|
||||
return 0
|
||||
return self.duration.total_seconds() / 60 / 60
|
||||
|
||||
@classmethod
|
||||
def add_minutes(cls, company, date, minutes):
|
||||
minutes = int(round(minutes))
|
||||
@@ -290,7 +298,7 @@ class Work:
|
||||
if values[work]['early_start_time']:
|
||||
early_finish_time = self.add_hours(work.company,
|
||||
values[work]['early_start_time'],
|
||||
work.duration)
|
||||
work.hours)
|
||||
values[work]['early_finish_time'] = early_finish_time
|
||||
|
||||
# Propagate constraint_start on successors
|
||||
@@ -370,7 +378,7 @@ class Work:
|
||||
if values[work]['late_finish_time']:
|
||||
late_start_time = self.add_hours(work.company,
|
||||
values[work]['late_finish_time'],
|
||||
-work.duration)
|
||||
-work.hours)
|
||||
values[work]['late_start_time'] = late_start_time
|
||||
|
||||
# Propagate constraint_finish on predecessors
|
||||
|
||||
Reference in new issue
Block a user