[ADD] Project_long_term: compute phase tasks date wizard => osv memory convert

bzr revid: mra@tinyerp.com-20100406105001-6pluzi9wopa3ewot
This commit is contained in:
mra (Open ERP)
2010-04-06 16:20:01 +05:30
parent 3ef0fea250
commit 5c6f3c1e58
5 changed files with 64 additions and 47 deletions
+2 -1
View File
@@ -43,7 +43,8 @@
"project_long_term_wizard.xml" ,
"project_long_term_view.xml",
"project_long_term_workflow.xml",
"wizard/project_compute_phases_view.xml"
"wizard/project_compute_phases_view.xml",
"wizard/project_compute_tasks_view.xml"
],
'installable': True,
'active': False,
@@ -4,7 +4,7 @@
<!--<wizard id="wizard_compute_phase" menu="False" model="project.phase" name="wizard.compute.phases" string="Compute Phase Scheduling"/>-->
<wizard id="wizard_schedule_task" menu="False" model="project.phase" name="phase.schedule.tasks" string="Schedule Tasks"/>
<wizard id="wizard_compute_task" model="project.task" menu="False" name="wizard.compute.tasks" string="Compute Task Scheduling"/>
<!--<wizard id="wizard_compute_task" model="project.task" menu="False" name="wizard.compute.tasks" string="Compute Task Scheduling"/>-->
<menuitem icon="terp-project" id="base.menu_main" name="Project Management" sequence="1"/>
<menuitem id="base.menu_pm_planning" name="Planning" parent="base.menu_main" sequence="3"/>
@@ -15,12 +15,12 @@
type="wizard"
sequence="1"/>
-->
<menuitem
<!-- <menuitem
action="wizard_compute_task"
id="menu_wizard_compute_task"
parent="base.menu_pm_planning"
type="wizard"
sequence="1"/>
-->
</data>
</openerp>
+1 -1
View File
@@ -20,7 +20,7 @@
##############################################################################
import project_compute_phases
import compute_tasks_date
import project_compute_tasks
import schedule_tasks
import working_calendar
@@ -23,38 +23,32 @@ from resource.faces import *
from new import classobj
import operator
from tools.translate import _
from osv import osv, fields
import working_calendar as wkcal
import wizard
import pooler
from tools.translate import _
class project_compute_tasks(osv.osv_memory):
_name = 'project.compute.tasks'
_description = 'Project Compute Tasks'
_columns = {
'project_id': fields.many2one('project.project', 'Project', required=True)
}
compute_form = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Tasks">
<field name="project_id" colspan="4"/>
</form>"""
success_msg = """<?xml version="1.0" ?>
<form string="Compute Scheduling of Tasks">
<label string="Task Scheduling completed successfully."/>
</form>"""
compute_fields = {
'project_id': {'string':'Project', 'type':'many2one', 'relation':'project.project', 'required':True},
}
class wizard_compute_tasks(wizard.interface):
def _compute_date(self, cr, uid, data, context):
def compute_date(self, cr, uid, ids, context=None):
"""
Schedule the tasks according to resource available and priority.
"""
pool = pooler.get_pool(cr.dbname)
project_obj = pool.get('project.project')
task_pool = pool.get('project.task')
resource_obj = pool.get('resource.resource')
user_obj = pool.get('res.users')
project_id = data['form']['project_id']
project_obj = self.pool.get('project.project')
task_pool = self.pool.get('project.task')
resource_obj = self.pool.get('resource.resource')
user_obj = self.pool.get('res.users')
if context is None:
context = {}
data = self.read(cr, uid, ids, [])[0]
project_id = data['project_id']
project = project_obj.browse(cr, uid, project_id, context=context)
task_ids = task_pool.search(cr, uid, [('project_id', '=', project_id),
('state', 'in', ['draft', 'open', 'pending'])
@@ -106,7 +100,7 @@ class wizard_compute_tasks(wizard.interface):
try:
resource = reduce(operator.or_, resources)
except:
raise wizard.except_wizard(_('Error'), _('Project must have members assigned !'))
raise osv.except_osv(_('Error'), _('Project must have members assigned !'))
minimum_time_unit = 1
if calendar_id: # If project has calendar
working_days = wkcal.compute_working_calendar(cr, uid, calendar_id)
@@ -142,20 +136,7 @@ class wizard_compute_tasks(wizard.interface):
'user_id': user_id[0]},
context=ctx)
loop_no +=1
return {}
return {} #improve me => Task Scheduling completed successfully => give this msg at end of wizard
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': compute_form, 'fields': compute_fields, 'state': [
('end', 'Cancel', 'gtk-cancel'),
('compute', 'Compute', 'gtk-ok', True)
]},
},
'compute': {
'actions': [_compute_date],
'result': {'type': 'form','arch': success_msg,'fields': {}, 'state': [('end', 'Ok')]},
}
}
wizard_compute_tasks('wizard.compute.tasks')
project_compute_tasks()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_project_compute_tasks" model="ir.ui.view">
<field name="name">Compute Task Scheduling</field>
<field name="model">project.compute.tasks</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Compute Scheduling of Phases">
<field name="project_id"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="_Cancel"/>
<button icon="gtk-ok" name="compute_date" string="Compute" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_project_compute_tasks" model="ir.actions.act_window">
<field name="name">Compute Task Scheduling</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">project.compute.tasks</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_project_compute_tasks"/>
<field name="context">{'record_id' : active_id}</field>
<field name="target">new</field>
</record>
<menuitem id="menu_compute_tasks" name="Compute Task Scheduling"
parent="base.menu_pm_planning" action="action_project_compute_tasks"/>
</data>
</openerp>