summaryrefslogtreecommitdiff
path: root/addons/project_long_term
diff options
context:
space:
mode:
authorksa (Open ERP) <ksa@tinyerp.co.in>2010-10-04 10:16:18 +0530
committerksa (Open ERP) <ksa@tinyerp.co.in>2010-10-04 10:16:18 +0530
commite30aaa320cf8469fe8d1ba4949099e0e5d72c7ed (patch)
treef5fe397da824eeeeccb12d61098fabdcababd775 /addons/project_long_term
parentb01c84b6bcd358a3eada8326099fa1e4d9bfc84c (diff)
parenta873250b8b51e97f20e49cf67a313484ea4b4e84 (diff)
[MERGE]: Merge with lp:openobject-addons-trunk
bzr revid: ksa@tinyerp.co.in-20101004044618-85iovhaz2xrivxj5
Diffstat (limited to 'addons/project_long_term')
-rw-r--r--addons/project_long_term/project_long_term.py40
-rw-r--r--addons/project_long_term/project_long_term_view.xml70
2 files changed, 92 insertions, 18 deletions
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index a535015d067..2caf36766b0 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -20,6 +20,7 @@
##############################################################################
from datetime import datetime
+from dateutil.relativedelta import relativedelta
from tools.translate import _
from osv import fields, osv
from resource.faces import task as Task
@@ -90,13 +91,26 @@ class project_phase(osv.osv):
model_data_obj = self.pool.get('ir.model.data')
model_data_id = model_data_obj._get_id(cr, uid, 'product', 'uom_hour')
return model_data_obj.read(cr, uid, [model_data_id], ['res_id'])[0]['res_id']
+
+ def _compute(self, cr, uid, ids, context=None):
+ res = {}
+ if not ids:
+ return res
+ for phase in self.browse(cr, uid, ids, context=context):
+ tot = 0.0
+ for task in phase.task_ids:
+ tot += task.planned_hours
+ res[phase.id] = {
+ 'total_hours' : tot
+ }
+ return res
_columns = {
'name': fields.char("Name", size=64, required=True),
'date_start': fields.date('Start Date', help="Starting Date of the phase", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'date_end': fields.date('End Date', help="Ending Date of the phase", states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
- 'constraint_date_start': fields.date('Start Date', help='force the phase to start after this date', states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
- 'constraint_date_end': fields.date('End Date', help='force the phase to finish before this date', states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
+ 'constraint_date_start': fields.date('Minimum Start Date', help='force the phase to start after this date', states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
+ 'constraint_date_end': fields.date('Deadline', help='force the phase to finish before this date', states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'project_id': fields.many2one('project.project', 'Project', required=True),
'next_phase_ids': fields.many2many('project.phase', 'project_phase_rel', 'prv_phase_id', 'next_phase_id', 'Next Phases', states={'cancelled':[('readonly',True)]}),
'previous_phase_ids': fields.many2many('project.phase', 'project_phase_rel', 'next_phase_id', 'prv_phase_id', 'Previous Phases', states={'cancelled':[('readonly',True)]}),
@@ -108,7 +122,8 @@ class project_phase(osv.osv):
'responsible_id': fields.many2one('res.users', 'Responsible', states={'done':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'state': fields.selection([('draft', 'Draft'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')], 'State', readonly=True, required=True,
help='If the phase is created the state \'Draft\'.\n If the phase is started, the state becomes \'In Progress\'.\n If review is needed the phase is in \'Pending\' state.\
- \n If the phase is over, the states is set to \'Done\'.')
+ \n If the phase is over, the states is set to \'Done\'.'),
+ 'total_hours': fields.function(_compute, method=True, string='Total Hours'),
}
_defaults = {
'responsible_id': lambda obj,cr,uid,context: uid,
@@ -130,6 +145,14 @@ class project_phase(osv.osv):
project_id = project_obj.browse(cr, uid, project, context=context)
result['date_start'] = project_id.date_start
return {'value': result}
+
+ def onchange_days(self, cr, uid, ids, project, context=None):
+ result = {}
+ for id in ids:
+ project_id = self.browse(cr, uid, id, context=context)
+ newdate = datetime.strptime(project_id.date_start, '%Y-%m-%d') + relativedelta(days=project_id.duration or 0.0)
+ result['date_end'] = newdate.strftime('%Y-%m-%d')
+ return {'value': result}
def _check_date_start(self, cr, uid, phase, date_end, context=None):
if context is None:
@@ -277,7 +300,6 @@ class project_phase(osv.osv):
context = {}
resource_pool = self.pool.get('resource.resource')
uom_pool = self.pool.get('product.uom')
- phase_resource = False
if context is None:
context = {}
default_uom_id = self._get_default_uom_id(cr, uid)
@@ -290,11 +312,11 @@ class project_phase(osv.osv):
duration = str(avg_hours) + 'H'
# Create a new project for each phase
def Project():
+ # If project has working calendar then that
+ # else the default one would be considered
start = start_date
minimum_time_unit = 1
resource = phase_resource_obj
- # If project has working calendar then that
- # else the default one would be considered
if calendar_id:
working_days = resource_pool.compute_working_calendar(cr, uid, calendar_id, context=context)
vacation = tuple(resource_pool.compute_vacation(cr, uid, calendar_id))
@@ -372,8 +394,10 @@ class project_resource_allocation(osv.osv):
_columns = {
'resource_id': fields.many2one('resource.resource', 'Resource', required=True),
'phase_id': fields.many2one('project.phase', 'Project Phase', ondelete='cascade', required=True),
- 'phase_id_date_start': fields.related('phase_id', 'date_start', type='date', string='Starting Date of the phase'),
- 'phase_id_date_end': fields.related('phase_id', 'date_end', type='date', string='Ending Date of the phase'),
+ 'project_id': fields.related('phase_id', 'project_id', type='many2one', relation="project.project", string='Project', store=True),
+ 'user_id': fields.related('resource_id', 'user_id', type='many2one', relation="res.users", string='User'),
+ 'date_start': fields.date('Start Date', help="Starting Date"),
+ 'date_end': fields.date('End Date', help="Ending Date"),
'useability': fields.float('Usability', help="Usability of this resource for this project phase in percentage (=50%)"),
}
_defaults = {
diff --git a/addons/project_long_term/project_long_term_view.xml b/addons/project_long_term/project_long_term_view.xml
index a3ff3b39669..3412ba7ca08 100644
--- a/addons/project_long_term/project_long_term_view.xml
+++ b/addons/project_long_term/project_long_term_view.xml
@@ -13,14 +13,27 @@
<field name="model">project.resource.allocation</field>
<field name="type">gantt</field>
<field name="arch" type="xml">
- <gantt color="phase_id" date_start="phase_id_date_start" date_stop="phase_id_date_end" string="R.A." mode="year">
- <level object="project.resource" link="resource_id" domain="[]">
- <field name="useability"/>
+ <gantt color="phase_id" date_start="date_start" date_stop="date_end" string="R.A." mode="year">
+ <level object="res.users" link="user_id" domain="[]">
+ <field name="useability" string="Availability"/>
</level>
</gantt>
</field>
</record>
+ <record id="view_project_resource_allocation_calendar" model="ir.ui.view">
+ <field name="name">project.resource.allocation.calendar</field>
+ <field name="model">project.resource.allocation</field>
+ <field name="type">calendar</field>
+ <field eval="2" name="priority"/>
+ <field name="arch" type="xml">
+ <calendar color="user_id" date_start="date_start" date_stop="date_end" day_length="12" string="Resources">
+ <field name="phase_id"/>
+ <field name="project_id"/>
+ </calendar>
+ </field>
+ </record>
+
<record id="view_project_resource_allocation_form" model="ir.ui.view">
<field name="name">project.resource.allocation.form</field>
@@ -28,9 +41,14 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Project Resource Allocation">
- <field name="resource_id" select="1"/>
- <field name="phase_id"/>
- <field name="useability" string="Availability"/>
+ <group colspan="4" col="6">
+ <field name="resource_id"/>
+ <field name="phase_id"/>
+ <field name="project_id"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
+ <field name="useability" string="Availability"/>
+ </group>
</form>
</field>
</record>
@@ -44,6 +62,7 @@
<tree editable="bottom" string="Project Resource Allocation">
<field name="resource_id"/>
<field name="phase_id"/>
+ <field name="project_id"/>
<field name="useability"/>
</tree>
</field>
@@ -58,11 +77,13 @@
<group colspan="4" col="20">
<field name="resource_id"/>
<field name="phase_id"/>
+ <field name="project_id"/>
</group>
<newline/>
<group expand="0" string="Group By..." colspan="4" col="20">
<filter name="resource" string="Resource" icon="terp-folder-blue" domain="[]" context="{'group_by':'resource_id'}"/>
<separator orientation="vertical"/>
+ <filter string="Project" icon="terp-project" domain="[]" context="{'group_by':'project_id'}"/>
<filter string="Phase" icon="terp-project" domain="[]" context="{'group_by':'phase_id'}"/>
</group>
</search>
@@ -73,7 +94,7 @@
<field name="name">Resource Allocations</field>
<field name="res_model">project.resource.allocation</field>
<field name="view_type">form</field>
- <field name="view_mode">tree,form,gantt</field>
+ <field name="view_mode">gantt,tree,form,calendar</field>
<field name="context">{}</field>
<field name="search_view_id" ref="view_project_resource_allocation_search"/>
</record>
@@ -97,7 +118,7 @@
<group colspan="2" col="4">
<field name="project_id" on_change="onchange_project(project_id)" colspan="4"/>
<newline/>
- <field name="duration" colspan="1"/>
+ <field name="duration" colspan="1" on_change="onchange_days(project_id)" />
<field name="product_uom" nolabel="1" domain="[('category_id.name', '=', 'Working Time')]"/>
</group>
<group colspan="2" col="2">
@@ -110,10 +131,14 @@
<field colspan="4" name="resource_ids" nolabel="1">
<tree editable="bottom" string="Project Resource Allocation">
<field name="resource_id" context="{'project_id':parent.project_id}"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
<field name="useability"/>
</tree>
<form string="Project Resource Allocation">
<field name="resource_id" context="{'project_id':parent.project_id}"/>
+ <field name="date_start"/>
+ <field name="date_end"/>
<field name="useability"/>
</form>
</field>
@@ -134,6 +159,7 @@
<field name="user_id"/>
<field name="planned_hours" widget="float_time"/>
<field name="project_id" invisible="1"/>
+ <field name="total_hours" sum='Total Hours'/>
</tree>
<form string="Project's Tasks">
<notebook colspan="4">
@@ -151,6 +177,7 @@
<group colspan="2" col="2">
<separator string="Planning" colspan="2"/>
<field name="planned_hours" widget="float_time"/>
+ <field name="total_hours" widget="float_time"/>
<field name="remaining_hours" widget="float_time" sum="Remaining Hours"/>
<field name="effective_hours" invisible="1"/>
</group>
@@ -263,7 +290,7 @@
<field name="name">Project Phases</field>
<field name="res_model">project.phase</field>
<field name="view_type">form</field>
- <field name="view_mode">tree,form,gantt,calendar</field>
+ <field name="view_mode">gantt,tree,form,calendar</field>
<field name="context">{'search_default_responsible_id':uid}</field>
<field name="search_view_id" ref="view_project_phase_search"/>
<field name="help">You can subdivide your larger projects into several phases. For each phase, you can define your resources allocation (humans or engine), describe de differend task and link your phase with previous and next one, add constraints date and scheduling. A gantt view of your project phase is also available from this menu. Gantt view is a graphically draw of the project plan; it includes any task dependencies by visually adjusting task durations and priorities, and by linking tasks to each other.</field>
@@ -299,7 +326,30 @@
# ------------------------------------------------------
# Project Task
# ------------------------------------------------------
-
+
+ <record id="view_phase_task_form2" model="ir.ui.view">
+ <field name="name">phase.task.form2</field>
+ <field name="model">project.task</field>
+ <field name="type">form</field>
+ <field name="inherit_id" ref="project.view_task_form2"/>
+ <field name="arch" type="xml">
+ <field name="sequence" position="after">
+ <field name="phase_id"/>
+ </field>
+ </field>
+ </record>
+ <record id="view_phase_task_search_form" model="ir.ui.view">
+ <field name="name">phase.task.search.form</field>
+ <field name="model">project.task</field>
+ <field name="type">search</field>
+ <field name="inherit_id" ref="project.view_task_search_form"/>
+ <field name="arch" type="xml">
+ <field name="project_id" position="after">
+ <field name="phase_id" select="1"/>
+ </field>
+ </field>
+ </record>
+
<act_window
id="project_phase_task_list"
name="Related Tasks"