1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as
9 # published by the Free Software Foundation, either version 3 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##############################################################################
22 from osv import fields, osv
25 class report_event_registration(osv.osv):
27 _name = "report.event.registration"
28 _description = "Events Analysis"
32 'date': fields.date('Event Start Date', readonly=True),
33 'year': fields.char('Year', size=4, readonly=True),
34 'month': fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
35 ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
36 ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
37 'event_id': fields.many2one('event.event', 'Event', required=True),
38 'draft_state': fields.integer(' # No of Draft Registrations', size=20),
39 'confirm_state': fields.integer(' # No of Confirmed Registrations', size=20),
40 'register_max': fields.integer('Maximum Registrations'),
41 'nbevent': fields.integer('Number Of Events'),
42 'type': fields.many2one('event.type', 'Event Type'),
43 'state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, required=True),
44 'user_id': fields.many2one('res.users', 'Responsible', readonly=True),
45 'speaker_id': fields.many2one('res.partner', 'Speaker', readonly=True),
46 'company_id': fields.many2one('res.company', 'Company', readonly=True),
47 'product_id': fields.many2one('product.product', 'Product', readonly=True),
48 'total': fields.float('Total'),
49 'section_id': fields.related('event_id', 'section_id', type='many2one', relation='crm.case.section', string='Sale Team', store=True, readonly=True),
54 initialize the sql view for the event registration
57 tools.drop_view_if_exists(cr, 'report_event_registration')
59 CREATE OR REPLACE view report_event_registration AS (
73 SUM(draft_state) AS draft_state,
74 SUM(confirm_state) AS confirm_state,
84 e.section_id AS section_id,
85 e.company_id AS company_id,
86 e.product_id AS product_id,
87 e.main_speaker_id AS speaker_id,
88 to_char(e.date_begin, 'YYYY') AS year,
89 to_char(e.date_begin, 'MM') AS month,
90 count(e.id) AS nbevent,
92 CASE WHEN c.state IN ('draft') THEN c.nb_register ELSE 0 END AS draft_state,
93 CASE WHEN c.state IN ('open','done') THEN c.nb_register ELSE 0 END AS confirm_state,
94 CASE WHEN c.state IN ('done') THEN c.price_subtotal ELSE 0 END AS total,
95 e.register_max AS register_max,
100 event_registration c ON (e.id=c.event_id)
102 event_type t ON (e.type=t.id)
103 WHERE c.active = 'true'
105 to_char(e.date_begin, 'YYYY'),
106 to_char(e.date_begin, 'MM'),
109 t.id, e.id, e.date_begin, e.main_speaker_id,
110 e.register_max, e.type, e.state, c.event_id, e.user_id,e.company_id,e.product_id,e.section_id,
111 to_char(e.date_begin, 'YYYY-MM-DD'), c.id, c.price_subtotal )AS foo
130 report_event_registration()
132 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: