[MERGE] trunk-bug-1022509-mdi: fix a group by in project's reporting

lp bug: https://launchpad.net/bugs/1022509 fixed

bzr revid: abo@openerp.com-20121010114853-tv06bu1wglcx5iy2
This commit is contained in:
Antonin Bourguignon 2012-10-10 13:48:53 +02:00
commit 69850d8c73
2 changed files with 33 additions and 59 deletions

View File

@ -1101,7 +1101,7 @@ class task(base_stage, osv.osv):
task_record = self.browse(cr, uid, task_id, context=context)
if task_record.project_id:
project_follower_ids = [follower.id for follower in task_record.project_id.message_follower_ids]
self.message_subscribe(cr, uid, [task_id], project_follower_ids,
self.message_subscribe(cr, uid, [task_id], project_follower_ids,
context=context)
self._store_history(cr, uid, [task_id], context=context)
self.create_send_note(cr, uid, [task_id], context=context)
@ -1354,16 +1354,15 @@ class project_project(osv.osv):
'use_tasks': True
}
#
# Tasks History, used for cumulative flow charts (Lean/Agile)
#
class project_task_history(osv.osv):
"""
Tasks History, used for cumulative flow charts (Lean/Agile)
"""
_name = 'project.task.history'
_description = 'History of Tasks'
_rec_name = 'task_id'
_log_access = False
def _get_date(self, cr, uid, ids, name, arg, context=None):
result = {}
for history in self.browse(cr, uid, ids, context=context):
@ -1415,35 +1414,38 @@ class project_task_history(osv.osv):
'date': fields.date.context_today,
}
class project_task_history_cumulative(osv.osv):
_name = 'project.task.history.cumulative'
_table = 'project_task_history_cumulative'
_inherit = 'project.task.history'
_auto = False
_columns = {
'end_date': fields.date('End Date'),
'project_id': fields.related('task_id', 'project_id', string='Project', type='many2one', relation='project.project')
'project_id': fields.many2one('project.project', 'Project'),
}
def init(self, cr):
cr.execute(""" CREATE OR REPLACE VIEW project_task_history_cumulative AS (
SELECT
history.date::varchar||'-'||history.history_id::varchar as id,
history.date as end_date,
history.date::varchar||'-'||history.history_id::varchar AS id,
history.date AS end_date,
*
FROM (
SELECT
id as history_id,
date+generate_series(0, CAST((coalesce(end_date,DATE 'tomorrow')::date - date)AS integer)-1) as date,
task_id, type_id, user_id, kanban_state, state,
greatest(remaining_hours,1) as remaining_hours, greatest(planned_hours,1) as planned_hours
h.id AS history_id,
h.date+generate_series(0, CAST((coalesce(h.end_date, DATE 'tomorrow')::date - h.date) AS integer)-1) AS date,
h.task_id, h.type_id, h.user_id, h.kanban_state, h.state,
greatest(h.remaining_hours, 1) AS remaining_hours, greatest(h.planned_hours, 1) AS planned_hours,
t.project_id
FROM
project_task_history
) as history
project_task_history AS h
JOIN project_task AS t ON (h.task_id = t.id)
) AS history
)
""")
class project_category(osv.osv):
""" Category of project's task (or issue) """
_name = "project.category"

View File

@ -18,10 +18,12 @@
</tree>
</field>
</record>
<record id="view_task_history_graph" model="ir.ui.view">
<field name="name">project.task.history.cumulative.graph</field>
<field name="model">project.task.history.cumulative</field>
<field name="arch" type="xml">
<!-- <field name="project_id"/> -->
<graph string="Project Tasks" type="bar">
<field name="date"/>
<field name="planned_hours" operator="+"/>
@ -29,21 +31,6 @@
</graph>
</field>
</record>
<!-- Where is this object in py file ? -->
<!--<record id="view_task_history_burndown_graph" model="ir.ui.view">-->
<!-- <field name="name">project.task.history.burndown.graph</field>-->
<!-- <field name="model">project.task.history.burndown</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <graph string="Burndown Chart of Tasks" type="bar">-->
<!-- <field name="date"/>-->
<!-- <field name="remaining_hours" operator="+"/>-->
<!-- <field name="type_id" group="True"/>-->
<!-- </graph>-->
<!-- </field>-->
<!--</record>-->
<record id="view_task_history_search" model="ir.ui.view">
<field name="name">project.task.history.cumulative.search</field>
@ -51,18 +38,18 @@
<field name="arch" type="xml">
<search string="Task's Analysis">
<field name="date"/>
<filter name="open" string="In Progress" domain="[('state','in',('open','draft'))]" help="In Progress Tasks" icon="terp-camera_test"/>
<filter string="Pending" domain="[('state','=','pending')]" context="{'show_delegated':False}" help="Pending Tasks" icon="terp-gtk-media-pause"/>
<separator/>
<filter name="kanban_blocked" string="Blocked" domain="[('kanban_state','=','blocked')]" icon="terp-gtk-media-pause"/>
<filter name="kanban_ready" string="Ready" domain="[('kanban_state','=','done')]" icon="terp-camera_test"/>
<separator/>
<filter string="My Tasks" domain="[('user_id','=',uid)]" help="My Tasks" icon="terp-personal" />
<filter string="Unassigned Tasks" domain="[('user_id','=',False)]" help="Unassigned Tasks" icon="terp-personal-" />
<separator/>
<filter string="My Projects" domain="[('project_id.user_id','=',uid)]" help="My Projects" icon="terp-personal"/>
<field name="project_id"/>
<field name="user_id"/>
<filter name="open" string="In Progress Tasks" domain="[('state','in',('open','draft'))]"/>
<filter string="Pending Tasks" domain="[('state','=','pending')]" context="{'show_delegated':False}"/>
<separator/>
<filter name="kanban_blocked" string="Blocked" domain="[('kanban_state','=','blocked')]"/>
<filter name="kanban_ready" string="Ready" domain="[('kanban_state','=','done')]"/>
<separator/>
<filter string="My Tasks" domain="[('user_id','=',uid)]"/>
<filter string="Unassigned Tasks" domain="[('user_id','=',False)]"/>
<separator/>
<filter string="My Projects" domain="[('project_id.user_id','=',uid)]"/>
</search>
</field>
</record>
@ -73,27 +60,12 @@
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="view_id" ref="view_task_history_graph"/>
<field eval="False" name="filter"/>
<field name="filter" eval="False"/>
<field name="context">{"search_default_open":1, "search_default_this_month": 1}</field>
</record>
<menuitem action="action_view_task_history_cumulative"
id="menu_action_view_task_history_cumulative"
parent="base.menu_project_report" />
<!--<record id="action_view_task_history_burndown" model="ir.actions.act_window">-->
<!-- <field name="name">Burndown Chart</field>-->
<!-- <field name="res_model">project.task.history.cumulative</field>-->
<!-- <field name="view_type">form</field>-->
<!-- <field name="view_mode">graph,tree</field>-->
<!-- <field name="view_id" ref="view_task_history_burndown_graph"/>-->
<!-- <field eval="False" name="filter"/>-->
<!-- <field name="context">{"search_default_open":1, "search_default_this_month": 1, "search_default_project_id": project_id}</field>-->
<!--</record>-->
<!--<menuitem action="action_view_task_history_burndown"-->
<!-- id="menu_action_view_task_history_burndown"-->
<!-- parent="project_report_task" />-->
parent="base.menu_project_report"/>
</data>
</openerp>