[FIX] Remove the executable flag on the python and xml files
[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')]"),
11         'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'project.issue')]"),
12         'nbr': fields.integer('# of Issues', readonly=True),
13         'delay_close': fields.float('Avg Closing Delay', digits=(16,2), readonly=True, group_operator="avg",
14                                        help="Number of Days to close the project issue"),
15         'company_id' : fields.many2one('res.company', 'Company'),
16         'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
17         'project_id':fields.many2one('project.project', 'Project',readonly=True),
18         'type_id': fields.many2one('crm.case.resource.type', 'Type', domain="[('object_id.model', '=', 'project.issue')]"),
19         'date_closed': fields.datetime('Close Date', readonly=True),
20         'assigned_to' : fields.many2one('res.users', 'Assigned to',readonly=True),
21         'partner_id': fields.many2one('res.partner','Partner',domain="[('object_id.model', '=', 'project.issue')]"),
22         'canal_id': fields.many2one('res.partner.canal', 'Channel',readonly=True),
23         'task_id': fields.many2one('project.task', 'Task',domain="[('object_id.model', '=', 'project.issue')]" )
24     }
25     def init(self, cr):
26         tools.drop_view_if_exists(cr, 'project_issue_report')
27         cr.execute("""
28             create or replace view project_issue_report as (
29                 select
30                     min(c.id) as id,
31                     to_char(c.create_date, 'YYYY') as name,
32                     to_char(c.create_date, 'MM') as month,
33                     to_char(c.create_date, 'YYYY-MM-DD') as day,
34                     c.state,
35                     c.user_id,
36                     c.section_id,
37                     c.categ_id,
38                     c.stage_id,
39                     to_char(c.date_closed, 'YYYY/mm/dd') as date_closed,
40                     u.company_id as company_id,
41                     c.priority as priority,
42                     c.project_id as project_id,
43                     c.type_id as type_id,
44                     count(*) as nbr,
45                     c.assigned_to,
46                     c.partner_id,
47                     c.canal_id,
48                     c.task_id,
49                     date_trunc('day',c.create_date) as create_date,
50                     avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as  delay_close
51                 from
52                     project_issue c
53                 left join
54                     res_users u on (c.id = u.id)
55                 group by
56                     to_char(c.create_date, 'YYYY'),
57                     to_char(c.create_date, 'MM'),
58                     to_char(c.create_date, 'YYYY-MM-DD'),
59                     c.state,
60                     c.user_id,
61                     c.section_id,
62                     c.categ_id,
63                     c.stage_id,
64                     c.date_closed,
65                     u.company_id,
66                     c.priority,
67                     c.project_id,
68                     c.type_id,
69                     date_trunc('day',c.create_date),
70                     c.assigned_to,
71                     c.partner_id,
72                     c.canal_id,
73                     c.task_id
74             )""")
75
76
77 project_issue_report()
78
79
80
81 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: