[IMP] website_project: display table of task by stage

bzr revid: chm@openerp.com-20130821085246-721xkh5bji0vqi9q
This commit is contained in:
Christophe Matthieu 2013-08-21 10:52:46 +02:00
parent ae8630a735
commit 1df99b0482
3 changed files with 69 additions and 20 deletions

View File

@ -16,10 +16,8 @@
<xpath expr="//body/header//ul[@id='top_menu']/li[last()]" position="before">
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</xpath>
<xpath expr="//body/footer//h5[@name='info_title']" position="after">
<ul class='unstyled'>
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</ul>
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<li><a href="/blog/%(website_mail.website_mail_blog)d/">News</a></li>
</xpath>
</template>

View File

@ -1,16 +1,43 @@
# -*- coding: utf-8 -*-
from openerp.osv import osv
from openerp.addons.web import http
from openerp.addons.web.http import request
class website_project(http.Controller):
@http.route(['/projects/'], type='http', auth="public")
def blog(self, **post):
website = request.registry['website']
class website(osv.osv):
_inherit = "website"
def get_rendering_context(self, additional_values=None):
project_obj = request.registry['project.project']
project_ids = project_obj.search(request.cr, request.uid, [('privacy_visibility', "=", "public")])
values = {
'project_ids': project_obj.browse(request.cr, request.uid, project_ids),
}
if additional_values:
values.update(additional_values)
return super(website, self).get_rendering_context(values)
class website_project(http.Controller):
@http.route(['/project/<int:project_id>/'], type='http', auth="public")
def blog(self, project_id=None, **post):
website = request.registry['website']
project_obj = request.registry['project.project']
task_obj = request.registry['project.task']
stage_obj = request.registry['project.task.type']
project = project_obj.browse(request.cr, request.uid, project_id)
domain = [('id', 'in', [task.id for task in project.tasks])]
stages = task_obj.read_group(request.cr, request.uid, domain, ["id", "stage_id"], groupby="stage_id")
for stage in stages:
stage['stage_id'] = stage_obj.browse(request.cr, request.uid, stage['stage_id'][0])
task_ids = task_obj.search(request.cr, request.uid, stage['__domain'])
stage['task_ids'] = task_obj.browse(request.cr, request.uid, task_ids)
values = website.get_rendering_context({
'project_ids': project_obj.browse(request.cr, request.uid, project_ids)
'project_id': project,
'stages': stages,
})
return website.render("website_project.index", values)

View File

@ -6,27 +6,51 @@
<!-- Layout add nav and footer -->
<template id="footer_custom" inherit_id="website.layout" name="Custom Footer">
<xpath expr="//body/header//ul[@id='top_menu']/li[last()]" position="before">
<li><a href="/projects/">Projects</a></li>
<xpath expr="//body/footer//div[@name='info']/ul" position="inside">
<li t-foreach="project_ids" t-as="project_id"><a t-attf-href="/project/#{ project_id.id }/"><t t-esc="project_id.name"/></a></li>
</xpath>
</template>
<!-- Page -->
<template id="index" name="Projects">
<template id="index" name="Project">
<t t-call="website.layout">
<t t-set="title">Projects</t>
<t t-set="title">Project</t>
<div class="container">
<div t-foreach="project_ids" t-as="project_id">
<h4 t-field="project_id.name"/>
<div t-foreach="project_id.tasks" t-as="task">
<a t-attf-href="/admin#view_type=form&amp;model=project.task&amp;id=#{task.id}"><span t-field="task.name"/></a>
</div>
</div>
<h4 t-field="project_id.name"/>
<table class="table">
<thead>
<tr>
<th t-foreach="stages" t-as="stage">
<span t-field="stage_id.name"/>
</th>
</tr>
</thead>
<tbody>
<tr>
<td t-foreach="stages" t-as="stage">
<div t-foreach="task_ids" t-as="task_id" class="thumbnail">
<a t-attf-href="/task/#{ task_id.id }/"><span t-field="task_id.name"/></a>
<div>
Assigned to <span t-field="task_id.user_id"/>
</div>
<div>
<span t-foreach="task_id.categ_ids" t-as="categ_id" class="label">
<t t-esc="categ_id.name"/>
</span>
</div>
<small>
<i class="icon-time"></i> <span t-field="task_id.date_start"/><br/>
<t t-if="task_id.date_end">Ending Date: <span t-field="task_id.date_end"/></t>
</small>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</template>
</data>
</openerp>