[ADD] Project_long_term: compute phase date wizard => osv memory convert
bzr revid: mra@tinyerp.com-20100406101827-6yhk7535fvxbhi2w
This commit is contained in:
parent
5ee2d53302
commit
3ef0fea250
|
@ -42,7 +42,8 @@
|
|||
"security/ir.model.access.csv",
|
||||
"project_long_term_wizard.xml" ,
|
||||
"project_long_term_view.xml",
|
||||
"project_long_term_workflow.xml"
|
||||
"project_long_term_workflow.xml",
|
||||
"wizard/project_compute_phases_view.xml"
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<wizard id="wizard_compute_phase" menu="False" model="project.phase" name="wizard.compute.phases" string="Compute Phase Scheduling"/>
|
||||
<!--<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"/>
|
||||
|
||||
<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"/>
|
||||
<menuitem
|
||||
<!-- <menuitem
|
||||
action="wizard_compute_phase"
|
||||
id="menu_wizard_compute_phase"
|
||||
parent="base.menu_pm_planning"
|
||||
type="wizard"
|
||||
sequence="1"/>
|
||||
|
||||
-->
|
||||
<menuitem
|
||||
action="wizard_compute_task"
|
||||
id="menu_wizard_compute_task"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-s
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
import compute_phases_date
|
||||
import project_compute_phases
|
||||
import compute_tasks_date
|
||||
import schedule_tasks
|
||||
import working_calendar
|
||||
|
|
|
@ -22,25 +22,19 @@ import datetime
|
|||
from resource.faces import *
|
||||
from new import classobj
|
||||
|
||||
import wizard
|
||||
import pooler
|
||||
from tools.translate import _
|
||||
from osv import fields, osv
|
||||
|
||||
import working_calendar as wkcal
|
||||
|
||||
compute_form = """<?xml version="1.0" ?>
|
||||
<form string="Compute Scheduling of Phases">
|
||||
class project_compute_phases(osv.osv_memory):
|
||||
|
||||
<field name="project_id" colspan="4"/>
|
||||
_name = 'project.compute.phases'
|
||||
_description = 'Project Compute Phases'
|
||||
_columns = {
|
||||
'project_id': fields.many2one('project.project', 'Project', help='If you do not specify project then it will take All projects with state=draft, open, pending')
|
||||
}
|
||||
|
||||
</form>"""
|
||||
|
||||
compute_fields = {
|
||||
'project_id': {'string':'Project', 'type':'many2one', 'relation':'project.project', 'help': 'If you do not specify project then it will take All projects with state=draft, open, pending'},
|
||||
|
||||
}
|
||||
|
||||
class wizard_compute_phases(wizard.interface):
|
||||
def _phase_schedule(self, cr, uid, phase, start_date, calendar_id=False, context={}):
|
||||
|
||||
"""Schedule phase with the start date till all the next phases are completed.
|
||||
|
@ -49,10 +43,9 @@ class wizard_compute_phases(wizard.interface):
|
|||
calendar_id -- working calendar of the project
|
||||
|
||||
"""
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
phase_obj = pool.get('project.phase')
|
||||
resource_obj = pool.get('resource.resource')
|
||||
uom_obj = pool.get('product.uom')
|
||||
phase_obj = self.pool.get('project.phase')
|
||||
resource_obj = self.pool.get('resource.resource')
|
||||
uom_obj = self.pool.get('product.uom')
|
||||
phase_resource_obj = False
|
||||
if phase:
|
||||
leaves = []
|
||||
|
@ -117,15 +110,18 @@ class wizard_compute_phases(wizard.interface):
|
|||
else:
|
||||
continue
|
||||
|
||||
def _compute_date(self, cr, uid, data, context={}):
|
||||
def compute_date(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Compute the phases for scheduling.
|
||||
"""
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
project_obj = pool.get('project.project')
|
||||
phase_obj = pool.get('project.phase')
|
||||
if data['form']['project_id']: # If project mentioned find its phases
|
||||
project_id = project_obj.browse(cr, uid, data['form']['project_id'], context=context)
|
||||
|
||||
if context is None:
|
||||
context = {}
|
||||
project_obj = self.pool.get('project.project')
|
||||
phase_obj = self.pool.get('project.phase')
|
||||
data = self.read(cr, uid, ids, [], context=context)[0]
|
||||
if data['project_id']: # If project mentioned find its phases
|
||||
project_id = project_obj.browse(cr, uid, data['project_id'], context=context)
|
||||
phase_ids = phase_obj.search(cr, uid, [('project_id', '=', project_id.id),
|
||||
('state', 'in', ['draft', 'open', 'pending']),
|
||||
('previous_phase_ids', '=', False)
|
||||
|
@ -143,37 +139,24 @@ class wizard_compute_phases(wizard.interface):
|
|||
start_dt = datetime.datetime.strftime((datetime.datetime.strptime(start_date, "%Y-%m-%d")), "%Y-%m-%d %H:%M")
|
||||
calendar_id = phase.project_id.resource_calendar_id and phase.project_id.resource_calendar_id.id or False
|
||||
self._phase_schedule(cr, uid, phase, start_dt, calendar_id, context=context)
|
||||
return {}
|
||||
return self._open_phases_list(cr, uid, data, context=context)
|
||||
|
||||
def _open_phases_list(self, cr, uid, data, context):
|
||||
def _open_phases_list(self, cr, uid, data, context=None):
|
||||
"""
|
||||
Return the scheduled phases list.
|
||||
"""
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
mod_obj = pool.get('ir.model.data')
|
||||
act_obj = pool.get('ir.actions.act_window')
|
||||
if context is None:
|
||||
context = {}
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
act_obj = self.pool.get('ir.actions.act_window')
|
||||
result = mod_obj._get_id(cr, uid, 'project_long_term', 'act_project_phase')
|
||||
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
|
||||
result = act_obj.read(cr, uid, [id], context=context)[0]
|
||||
result['domain'] = [('state', 'not in', ['cancelled','done'])]
|
||||
if data['form']['project_id']:
|
||||
result['domain'] = [('project_id', '=', data['form']['project_id']),
|
||||
if data['project_id']:
|
||||
result['domain'] = [('project_id', '=', data['project_id']),
|
||||
('state', 'not in', ['cancelled','done'])]
|
||||
return result
|
||||
|
||||
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': 'action', 'action': _open_phases_list, 'state': 'end'},
|
||||
},
|
||||
}
|
||||
wizard_compute_phases('wizard.compute.phases')
|
||||
project_compute_phases()
|
||||
# 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_phases" model="ir.ui.view">
|
||||
<field name="name">Compute Scheduling of Phases</field>
|
||||
<field name="model">project.compute.phases</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_phases" model="ir.actions.act_window">
|
||||
<field name="name">Compute Phase Scheduling</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">project.compute.phases</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_project_compute_phases"/>
|
||||
<field name="context">{'record_id' : active_id}</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_compute_phase" name="Compute Phase Scheduling"
|
||||
parent="base.menu_pm_planning" action="action_project_compute_phases"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue