[ADD] Project_issue Module (Added missing module)
[odoo/odoo.git] / addons / project_issue / report / project_issue_report.py
1 from osv import fields,osv
2 import tools
3 from crm import crm
4
5 class project_issue_report(osv.osv):
6     _name = "project.issue.report"
7     _auto = False
8     _inherit = "crm.case.report"
9     _columns = {
10         'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'project.issue.report')]"),
11         'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'project.issue.report')]"),
12         'nbr': fields.integer('# of Issues', reaadonly=True),
13         'delay_close': fields.char('Delay to close', size=20, readonly=True),
14         'company_id' : fields.many2one('res.company', 'Company'),
15         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
16         'project_id':fields.many2one('project.project', 'Project'),
17         'type_id': fields.many2one('crm.case.resource.type', 'Bug Type', domain="[('object_id.model', '=', 'project.issue')]"),
18         'date_closed': fields.datetime('Close Date', readonly=True),
19     }
20     def init(self, cr):
21         tools.drop_view_if_exists(cr, 'project_issue_report')
22         cr.execute("""
23             create or replace view project_issue_report as (
24                 select
25                     min(c.id) as id,
26                     to_char(c.create_date, 'YYYY') as name,
27                     to_char(c.create_date, 'MM') as month,
28                     c.state,
29                     c.user_id,
30                     c.section_id,
31                     c.categ_id,
32                     c.stage_id,
33                     to_char(c.date_closed, 'YYYY/mm/dd') as date_closed,
34                     u.company_id as company_id,
35                     c.priority as priority,
36                     c.project_id as project_id,
37                     c.type_id as type_id,
38                     count(*) as nbr,                    
39                     to_char(avg(date_closed-c.create_date), 'DD"d" HH24:MI:SS') as delay_close
40                 from
41                     project_issue c
42                 left join
43                     res_users u on (c.id = u.id)
44                 group by to_char(c.create_date, 'YYYY'), to_char(c.create_date, 'MM'), c.state, c.user_id,c.section_id,c.categ_id,c.stage_id
45                 ,c.date_closed,u.company_id,c.priority,c.project_id,c.type_id
46             )""")
47
48
49 project_issue_report()
50
51
52 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: