2 # -*- coding: utf-8 -*-
3 ##############################################################################
5 # OpenERP, Open Source Management Solution
6 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as
10 # published by the Free Software Foundation, either version 3 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from osv import fields,osv
30 ('cancel', 'Cancelled'),
34 class project_issue_report(osv.osv):
35 _name = "project.issue.report"
39 'name': fields.char('Year', size=64, required=False, readonly=True),
40 'user_id':fields.many2one('res.users', 'Responsible', readonly=True),
41 'section_id':fields.many2one('crm.case.section', 'Section', readonly=True),
42 'state': fields.selection(AVAILABLE_STATES, 'State', size=16, readonly=True),
43 'month':fields.selection([('01', 'January'), ('02', 'February'), \
44 ('03', 'March'), ('04', 'April'),\
45 ('05', 'May'), ('06', 'June'), \
46 ('07', 'July'), ('08', 'August'),\
47 ('09', 'September'), ('10', 'October'),\
48 ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
49 'company_id': fields.many2one('res.company', 'Company', readonly=True),
50 'day': fields.char('Day', size=128, readonly=True),
51 'opening_date': fields.date('Date of Opening', readonly=True),
52 'creation_date': fields.date('Creation Date', readonly=True),
53 'date_closed': fields.date('Date of Closing', readonly=True),
54 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('section_id','=',section_id),('object_id.model', '=', 'project.issue')]"),
55 'type_id': fields.many2one('project.task.type', 'Stage'),
56 'nbr': fields.integer('# of Issues', readonly=True),
57 'working_hours_open': fields.float('Avg. Working Hours to Open', readonly=True),
58 'working_hours_close': fields.float('Avg. Working Hours to Close', readonly=True),
59 'delay_open': fields.float('Avg. Delay to Open', digits=(16,2), readonly=True, group_operator="avg",
60 help="Number of Days to close the project issue"),
61 'delay_close': fields.float('Avg. Delay to Close', digits=(16,2), readonly=True, group_operator="avg",
62 help="Number of Days to close the project issue"),
63 'company_id' : fields.many2one('res.company', 'Company'),
64 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
65 'project_id':fields.many2one('project.project', 'Project',readonly=True),
66 'version_id': fields.many2one('project.issue.version', 'Version'),
67 'assigned_to' : fields.many2one('res.users', 'Assigned to',readonly=True),
68 'partner_id': fields.many2one('res.partner','Partner',domain="[('object_id.model', '=', 'project.issue')]"),
69 'canal_id': fields.many2one('res.partner.canal', 'Channel',readonly=True),
70 'task_id': fields.many2one('project.task', 'Task',domain="[('object_id.model', '=', 'project.issue')]" ),
71 'email': fields.integer('# Emails', size=128, readonly=True),
75 tools.drop_view_if_exists(cr, 'project_issue_report')
77 CREATE OR REPLACE VIEW project_issue_report AS (
80 to_char(c.create_date, 'YYYY') as name,
81 to_char(c.create_date, 'MM') as month,
82 to_char(c.create_date, 'YYYY-MM-DD') as day,
83 to_char(c.date_open, 'YYYY-MM-DD') as opening_date,
84 to_char(c.create_date, 'YYYY-MM-DD') as creation_date,
88 c.working_hours_close,
92 to_char(c.date_closed, 'YYYY-mm-dd') as date_closed,
93 c.company_id as company_id,
94 c.priority as priority,
95 c.project_id as project_id,
96 c.version_id as version_id,
102 date_trunc('day',c.create_date) as create_date,
103 extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open,
104 extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
105 (SELECT count(id) FROM mailgate_message WHERE model='project.issue' AND res_id=c.id) AS email
109 where c.categ_id in (select res_id from ir_model_data where name='bug_categ')
111 to_char(c.create_date, 'YYYY'),
112 to_char(c.create_date, 'MM'),
113 to_char(c.create_date, 'YYYY-MM-DD'),
115 to_char(c.date_open, 'YYYY-MM-DD'),
116 to_char(c.date_closed, 'YYYY-mm-dd'),
123 c.working_hours_open,
124 c.working_hours_close,
126 to_char(c.date_closed, 'YYYY-MM-DD'),
128 c.working_hours_open,
129 c.working_hours_close,
130 date_trunc('day',c.create_date),
137 project_issue_report()
139 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: