~pedro.baeza/c2c-rd-addons/7.0-mrp_no_gap_imp

« back to all changes in this revision

Viewing changes to project_task_dependencies/project.py

  • Committer: ferdinand
  • Date: 2013-12-07 14:27:10 UTC
  • Revision ID: office@chrcar.at-20131207142710-ssw4pasu318bzkk0
[REF] compute start+end dates respecing duration

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        , ('Minutes', _('Minutes'))
43
43
        ]
44
44
 
 
45
    def _duration(self, cr, uid, ids, field_name, arg, context=None):
 
46
        if context is None:
 
47
            context = {}        
 
48
        for task in self.browse(cr, uid, task_ids, context):
 
49
            if task.date_start and task.date_end:
 
50
                #_logger.debug('FGF date change %s %s' % (date_start, date_end ))
 
51
                from_date = datetime.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')
 
52
                to_date = datetime.strptime(task.date_end,'%Y-%m-%d %H:%M:%S')
 
53
                duration = (to_date - from_date).days
 
54
            else:
 
55
                duration = ''
 
56
            #return {'value': {'duration': duration }}
 
57
            res[task.id] = duration
 
58
        return res
 
59
    
45
60
    _columns = {
46
61
        'predecessor_ids': one2many_sorted.many2many_sorted('project.task',
47
62
                                            'task_predecessors_rel',
53
68
                                            'predecessor_id','task_id',
54
69
                                            'Task Successor',
55
70
                                             order = 'date_start, name' ),
56
 
        'duration': fields.integer('Duration',digits=(4)),
 
71
        #'duration': fields.integer('Duration',digits=(4)),
 
72
        'duration': fields.function(_duration, type='integer', string="Duration"),
57
73
        'duration_min': fields.integer('Minimum Duration', digits=(4), help="Minimum duration in duration_unit. If not set it is computed automatically as difference between start and end date"),
58
74
        'duration_unit': fields.selection(_duration_units, 'Duration Unit', required=True, help="Currently only days are supported"),
59
75
        'compute_dependency': fields.boolean('Compute earliest start date', help="If set we compute the earliest start date of this task and of all marked successors and based on date for start and end or deadline if end not set"),