fix
[odoo/odoo.git] / addons / project_long_term / project_long_term.py
index 8588b90..4ab1722 100644 (file)
@@ -23,7 +23,6 @@ from datetime import datetime
 from tools.translate import _
 from osv import fields, osv
 from resource.faces import task as Task
-from operator import itemgetter
 
 class project_phase(osv.osv):
     _name = "project.phase"
@@ -223,65 +222,7 @@ class project(osv.osv):
     _inherit = "project.project"
     _columns = {
         'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"),
-        'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report", states={'close':[('readonly',True)]} ),
     }
-    def _schedule_header(self, cr, uid, ids, context=None):
-        context = context or {}
-        if type(ids) in (long, int,):
-            ids = [ids]
-        projects = self.browse(cr, uid, ids, context=context)
-
-        for project in projects:
-            if not project.members:
-                raise osv.except_osv(_('Warning !'),_("You must assign members on the project '%s' !") % (project.name,))
-
-        resource_pool = self.pool.get('resource.resource')
-
-        result = "from resource.faces import *\n"
-        result += "import datetime\n"
-        for project in self.browse(cr, uid, ids, context=context):
-            u_ids = [i.id for i in project.members]
-            for task in project.tasks:
-                if task.state in ('done','cancelled'):
-                    continue
-                if task.user_id and (task.user_id.id not in u_ids):
-                    u_ids.append(task.user_id.id)
-            calendar_id = project.resource_calendar_id and project.resource_calendar_id.id or False
-            resource_objs = resource_pool.generate_resources(cr, uid, u_ids, calendar_id, context=context)
-            for key, vals in resource_objs.items():
-                result +='''
-class User_%s(Resource):
-    efficiency = %s
-''' % (key,  vals.get('efficiency', False))
-
-        result += '''
-def Project():
-        '''
-        return result
-
-    def _schedule_project(self, cr, uid, project, context=None):
-        resource_pool = self.pool.get('resource.resource')
-        calendar_id = project.resource_calendar_id and project.resource_calendar_id.id or False
-        working_days = resource_pool.compute_working_calendar(cr, uid, calendar_id, context=context)
-        # TODO: check if we need working_..., default values are ok.
-        result = """
-  def Project_%d():
-    start = \'%s\'
-    working_days = %s
-    resource = %s
-"""       % (
-            project.id, 
-            project.date_start, working_days,
-            '|'.join(['User_'+str(x.id) for x in project.members])
-        )
-        vacation = calendar_id and tuple(resource_pool.compute_vacation(cr, uid, calendar_id, context=context)) or False
-        if vacation:
-            result+= """
-    vacation = %s
-""" %   ( vacation, )
-        return result
-
-
     def schedule_phases(self, cr, uid, ids, context=None):
         context = context or {}
         if type(ids) in (long, int,):
@@ -321,45 +262,6 @@ def Project():
                     'date_end': p.end.strftime('%Y-%m-%d %H:%M:%S')
                 }, context=context)
         return True
-
-    #TODO: DO Resource allocation and compute availability
-    def compute_allocation(self, rc, uid, ids, start_date, end_date, context=None):
-        if context ==  None:
-            context = {}
-        allocation = {}
-        return allocation
-
-    def schedule_tasks(self, cr, uid, ids, context=None):
-        context = context or {}
-        if type(ids) in (long, int,):
-            ids = [ids]
-        projects = self.browse(cr, uid, ids, context=context)
-        result = self._schedule_header(cr, uid, ids, context=context)
-        for project in projects:
-            result += self._schedule_project(cr, uid, project, context=context)
-            result += self.pool.get('project.task')._generate_task(cr, uid, project.tasks, ident=4, context=context)
-
-        local_dict = {}
-        exec result in local_dict
-        projects_gantt = Task.BalancedProject(local_dict['Project'])
-
-        for project in projects:
-            project_gantt = getattr(projects_gantt, 'Project_%d' % (project.id,))
-            for task in project.tasks:
-                if task.state in ('done','cancelled'):
-                    continue
-
-                p = getattr(project_gantt, 'Task_%d' % (task.id,))
-
-                self.pool.get('project.task').write(cr, uid, [task.id], {
-                    'date_start': p.start.strftime('%Y-%m-%d %H:%M:%S'),
-                    'date_end': p.end.strftime('%Y-%m-%d %H:%M:%S')
-                }, context=context)
-                if (not task.user_id) and (p.booked_resource):
-                    self.pool.get('project.task').write(cr, uid, [task.id], {
-                        'user_id': int(p.booked_resource[0].name[5:]),
-                    }, context=context)
-        return True
 project()
 
 class project_task(osv.osv):
@@ -367,30 +269,6 @@ class project_task(osv.osv):
     _columns = {
         'phase_id': fields.many2one('project.phase', 'Project Phase'),
     }
-    def _generate_task(self, cr, uid, tasks, ident=4, context=None):
-        context = context or {}
-        result = ""
-        ident = ' '*ident
-        for task in tasks:
-            if task.state in ('done','cancelled'):
-                continue
-            result += '''
-%sdef Task_%s():
-%s  todo = \"%.2fH\"
-%s  effort = \"%.2fH\"''' % (ident,task.id, ident,task.remaining_hours, ident,task.total_hours)
-            start = []
-            for t2 in task.parent_ids:
-                start.append("up.Task_%s.end" % (t2.id,))
-            if start:
-                result += '''
-%s  start = max(%s)
-''' % (ident,','.join(start))
-
-            if task.user_id:
-                result += '''
-%s  resource = %s
-''' % (ident, 'User_'+str(task.user_id.id))
-
-        result += "\n"
-        return result
 project_task()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: