示例#1
0
 def equal(self, a, b):
     # mx.DateTime has a precision of 10ms, so we need to account for
     # rounding errors.
     datetime_types = DateTime.DateTimeType, DateTime.DateTimeDeltaType
     if isinstance(a, datetime_types) and isinstance(b, datetime_types):
         return DateTime.cmp(a, b, 0.01) == 0
     return a == b
示例#2
0
 def equal(self, a, b):
     # mx.DateTime has a precision of 10ms, so we need to account for
     # rounding errors.
     datetime_types = DateTime.DateTimeType, DateTime.DateTimeDeltaType
     if isinstance(a, datetime_types) and isinstance(b, datetime_types):
         return DateTime.cmp(a, b, 0.01) == 0
     return a == b
示例#3
0
 def _ops(self, op, other):
     if isinstance(other, basestring):
         try:
             other = self.__class__(other)
         except Error:
             pass
     if isinstance(other, DatetimeFormat):
         other = other._value
     if self._value is None or other is None:
         return op(self._value, other)
     try:
         return op(DateTime.cmp(self._value, other, self.precision), 0)
     except TypeError, e:
         raise TypeError('%s: %r vs %r' % (e, self._value, other))
示例#4
0
def _compute_tasks(cr, uid, task_list, date_begin):
    sequences = []
    users = {}
    tasks = {}
    last_date = date_begin
    for task in task_list:
        # TODO: reorder ! with dependencies
        if not task.planned_hours:
            continue
        if task.state in ('draft','open','progress') and task.user_id:

            # Find the starting date of the task
            if task.user_id.id in users:
                date_start = users[task.user_id.id]
            else:
                date_start = date_begin
            sequences.sort()
            for (seq,dt) in sequences:
                if seq<task.sequence:
                    date_start = max(dt,date_start)
                else:
                    break

            if task.date_start:
                task_date_start = DateTime.strptime(task.date_start, '%Y-%m-%d %H:%M:%S')
                if DateTime.cmp(date_start, task_date_start) < 0:
                    date_start = task_date_start


            # Compute the closing date of the task
            tasks[task.id] = []
            res = pooler.get_pool(cr.dbname).get('hr.timesheet.group').interval_get(cr, uid, task.project_id.timesheet_id.id, date_start, task.remaining_hours)
            for (d1,d2) in res:
                tasks[task.id].append((d1, d2, task.name, task.user_id.login))
            date_close = tasks[task.id] and tasks[task.id][-1][1] or False

            # Store result
            if date_close:
                users[task.user_id.id] = date_close
                sequences.append((task.sequence, date_close))
                if date_close>last_date:
                    last_date=date_close
    return tasks, last_date