summaryrefslogtreecommitdiff
path: root/addons/project_long_term
diff options
context:
space:
mode:
authorHDA (OpenERP) <hda@tinyerp.com>2010-01-29 20:15:15 +0530
committerHDA (OpenERP) <hda@tinyerp.com>2010-01-29 20:15:15 +0530
commit6b501495dbff6a12de648f04744c20f2e294e6d7 (patch)
tree9b1dc0e1f494c8be25ce3b0a9bbba0475d90e938 /addons/project_long_term
parent9aa55b69a29ccf6d0c7f34376aced8f65306d482 (diff)
parent6632a6a64651d4a5893c77fc37725a05b3b1d26c (diff)
Added faces files and integration with project
bzr revid: hda@tinyerp.com-20100129144515-7xojyodjw7fgodhe
Diffstat (limited to 'addons/project_long_term')
-rw-r--r--addons/project_long_term/__init__.py1
-rw-r--r--addons/project_long_term/__terp__.py3
-rw-r--r--addons/project_long_term/project.py11
-rw-r--r--addons/project_long_term/project_wizard.xml12
-rw-r--r--addons/project_long_term/wizard/__init__.py25
-rw-r--r--addons/project_long_term/wizard/compute_phases_date.py196
6 files changed, 234 insertions, 14 deletions
diff --git a/addons/project_long_term/__init__.py b/addons/project_long_term/__init__.py
index 33adeb520b9..5a6ad27710f 100644
--- a/addons/project_long_term/__init__.py
+++ b/addons/project_long_term/__init__.py
@@ -20,6 +20,7 @@
##############################################################################
import project
+import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/__terp__.py b/addons/project_long_term/__terp__.py
index 1b5dfa348ad..23a1b2a6297 100644
--- a/addons/project_long_term/__terp__.py
+++ b/addons/project_long_term/__terp__.py
@@ -33,7 +33,8 @@
"demo_xml" : [#"project_demo.xml"
],
"update_xml": [
- "project_view.xml",
+ "project_view.xml",
+ "project_wizard.xml"
],
'installable': True,
'active': False,
diff --git a/addons/project_long_term/project.py b/addons/project_long_term/project.py
index c5734263ea5..3f16b33ea31 100644
--- a/addons/project_long_term/project.py
+++ b/addons/project_long_term/project.py
@@ -125,17 +125,6 @@ class task(osv.osv):
_columns = {
'phase_id': fields.many2one('project.phase', 'Project Phase')
}
- def _check_dates(self, cr, uid, ids):
- leave = self.read(cr, uid, ids[0],['date_start','date_end'])
- if leave['date_start'] and leave['date_end']:
- if leave['date_start'] > leave['date_end']:
- return False
- return True
-
- _constraints = [
- (_check_dates, 'Error! task start-date must be lower then task end-date.', ['date_start', 'date_end'])
- ]
-
task()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/project_long_term/project_wizard.xml b/addons/project_long_term/project_wizard.xml
index 109a003da4a..5fb0b101fa6 100644
--- a/addons/project_long_term/project_wizard.xml
+++ b/addons/project_long_term/project_wizard.xml
@@ -1,8 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
- <wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>
+ <!-- <wizard id="wizard_close_task" menu="False" model="project.task" name="project.task.close" string="Close Task"/>
<wizard id="wizard_delegate_task" menu="False" model="project.task" name="project.task.delegate" string="Delegate Task"/>
- <wizard id="wizard_attachment_task" model="project.task" name="project.task.attachment" string="All Attachments"/>
+ <wizard id="wizard_attachment_task" model="project.task" name="project.task.attachment" string="All Attachments"/> -->
+ <wizard id="wizard_compute_phase" model="project.phase" name="wizard.compute.phases" string="Compute Phase Scheduling"/>
+ <menuitem icon="terp-project" id="menu_main" name="Project Management"/>
+ <menuitem
+ action="wizard_compute_phase"
+ id="menu_wizard_compute_phase"
+ parent="menu_main"
+ type="wizard"
+ sequence="1"/>
</data>
</openerp>
diff --git a/addons/project_long_term/wizard/__init__.py b/addons/project_long_term/wizard/__init__.py
new file mode 100644
index 00000000000..a38c9720ebc
--- /dev/null
+++ b/addons/project_long_term/wizard/__init__.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import compute_phases_date
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/project_long_term/wizard/compute_phases_date.py b/addons/project_long_term/wizard/compute_phases_date.py
new file mode 100644
index 00000000000..8b3c76c9ef3
--- /dev/null
+++ b/addons/project_long_term/wizard/compute_phases_date.py
@@ -0,0 +1,196 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import wizard
+import pooler
+from tools.translate import _
+import datetime
+from resource.faces import *
+
+compute_form = """<?xml version="1.0" ?>
+<form string="Compute Scheduling of Tasks">
+
+ <field name="project_id" colspan="4"/>
+
+</form>"""
+
+compute_fields = {
+ 'project_id': {'string':'Project', 'type':'many2one', 'relation': 'project.project', 'required':'True'},
+
+}
+def timeformat_convert(cr, uid, time_string, context={}):
+ strg = str(time_string)[-2:]
+ last_strg = str(time_string)[0:-2]
+ if strg != '.0':
+ if '.' not in strg:
+ strg = '.' + strg
+ last_strg = str(time_string)[:-3]
+
+ new_strg = round(float(strg) / 0.016666667)
+ converted_strg = last_strg + ':' + str(new_strg)[:-2]
+ else:
+ converted_strg = last_strg + ':00'
+
+ return converted_strg
+
+class wizard_compute_phases(wizard.interface):
+
+ def _compute_date(self, cr, uid, data, context):
+ project_id = data['form']['project_id']
+ project = pooler.get_pool(cr.dbname).get('project.project').browse(cr,uid,project_id)
+ phase_ids = pooler.get_pool(cr.dbname).get('project.phase').search(cr,uid,[('project_id','=',project_id)])
+ if phase_ids:
+ phase_obj = pooler.get_pool(cr.dbname).get('project.phase').browse(cr,uid,phase_ids)
+ phase_1 = phase_obj[0]
+ if phase_1.date_start:
+ date_dt = datetime.datetime.strptime(phase_1.date_start,"%Y-%m-%d %H:%M:%S")
+ else:
+ date_dt = datetime.datetime.strptime(project.date_start,"%Y-%m-%d")
+ dt = datetime.datetime.strftime(date_dt,"%Y-%m-%d %H:%M")
+
+ for i in range(len(phase_obj)):
+ final_lst = []
+ leaves = []
+# if phase_obj[i].user_id.id:
+# resource_id = pooler.get_pool(cr.dbname).get('resource.resource').search(cr,uid,[('user_id','=',task_obj[i].user_id.id)])
+# resource_obj = pooler.get_pool(cr.dbname).get('resource.resource').browse(cr,uid,resource_id)[0]
+ if project.resource_calendar_id:
+ non_working = ""
+ time_range = "8:00-8:00"
+ wk = {"0":"mon","1":"tue","2":"wed","3":"thu","4":"fri"}
+ wk_days = {}
+ wk_time = {}
+ tlist = []
+ hours = []
+ hr = 0
+
+ week_ids = pooler.get_pool(cr.dbname).get('resource.calendar.week').search(cr,uid,[('calendar_id','=',project.resource_calendar_id.id)])
+ week_obj = pooler.get_pool(cr.dbname).get('resource.calendar.week').read(cr,uid,week_ids,['dayofweek','hour_from','hour_to'])
+
+ for week in week_obj:
+ res_str = ""
+ if wk.has_key(week['dayofweek']):
+ day = wk[week['dayofweek']]
+ wk_days[week['dayofweek']] = wk[week['dayofweek']]
+
+ hour_from_str = timeformat_convert(cr,uid,week['hour_from'])
+ hour_to_str = timeformat_convert(cr,uid,week['hour_to'])
+ hours.append(week['hour_from'])
+ hours.append(week['hour_to'])
+ res_str = hour_from_str + '-' + hour_to_str
+ tlist.append((day,res_str))
+
+ for item in tlist:
+ if wk_time.has_key(item[0]):
+ wk_time[item[0]].append(item[1])
+ else:
+ wk_time[item[0]] = [item[0]]
+ wk_time[item[0]].append(item[1])
+
+ for k,v in wk_time.items():
+ final_lst.append(tuple(v))
+
+ for k,v in wk_days.items():
+ if wk.has_key(k):
+ wk.pop(k)
+ for v in wk.itervalues():
+ non_working += v + ','
+ if non_working:
+ final_lst.append((non_working[:-1],time_range))
+
+ leave_ids = pooler.get_pool(cr.dbname).get('resource.calendar.leaves').search(cr,uid,[('calendar_id','=',project.resource_calendar_id.id)])
+ if leave_ids:
+ res_leaves = pooler.get_pool(cr.dbname).get('resource.calendar.leaves').read(cr,uid,leave_ids,['date_from','date_to'])
+ for leave in range(len(res_leaves)):
+ dt_start = datetime.datetime.strptime(res_leaves[leave]['date_from'],'%Y-%m-%d %H:%M:%S')
+ dt_end = datetime.datetime.strptime(res_leaves[leave]['date_to'],'%Y-%m-%d %H:%M:%S')
+ no = dt_end - dt_start
+ leave_days = no.days + 1
+ [leaves.append((dt_start + datetime.timedelta(days=x)).strftime('%Y-%m-%d')) for x in range(int(leave_days))]
+ leaves.sort()
+
+ for hour in range(0,4):
+ if hour%2 ==0:
+ hr += float(hours[hour+1]) - float(hours[hour])
+
+ man_days = str(phase_obj[i].duration * hr)[:-2] + 'H'
+
+ if i == 0:
+ new_dt = dt
+ else:
+ data = pooler.get_pool(cr.dbname).get('project.phase').read(cr,uid,[phase_obj[i-1].id],['date_end'])[0]
+ if phase_obj[i].constraint_date_start and data['date_end'] < phase_obj[i].constraint_date_start:
+ new_dt = phase_obj[i].constraint_date_start[0:16]
+ else:
+ new_dt = data['date_end'][0:16]
+
+ class user(Resource):
+ pass
+
+ def Project_1():
+ resource = user
+ title = project.name
+ start = new_dt
+ effort = man_days
+
+ if final_lst or leaves:
+ working_days = final_lst
+ vacation = tuple(leaves)
+
+ def phase1():
+ start = new_dt
+ effort = man_days
+ title = phase_obj[i].name
+
+ project_1 = BalancedProject(Project_1)
+ start_date = project_1.calendar.WorkingDate(project_1.phase1.start).to_datetime()
+ e_date = project_1.calendar.WorkingDate(project_1.phase1.end).to_datetime()
+ if phase_obj[i].constraint_date_end and str(e_date) > phase_obj[i].constraint_date_end:
+ end_date = phase_obj[i].constraint_date_end
+ else:
+ end_date = e_date
+
+ pooler.get_pool(cr.dbname).get('project.phase').write(cr,uid,[phase_obj[i].id],{'date_start':start_date,'date_end':end_date})
+
+ return {}
+ states = {
+ 'init': {
+ 'actions': [],
+ 'result': {'type':'form', 'arch':compute_form, 'fields':compute_fields, 'state':[
+ ('end', 'Cancel'),
+ ('ok', 'Ok')
+
+ ]},
+ },
+ 'ok': {
+ 'actions': [_compute_date],
+ 'result': {'type':'state', 'state':'end'},
+ }
+ }
+wizard_compute_phases('wizard.compute.phases')
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+