From 79b29e17c4966f0be4f6bc42397c156e6e2d7e49 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Wed, 25 Jul 2012 12:59:52 +0530 Subject: [PATCH 1/6] [FIX]remove ProgrammingError in event module bzr revid: shp@tinyerp.com-20120725072952-mcnyappum33w1smy --- addons/event/report/report_event_registration.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index 17472e0cc95..59515f87a00 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -80,6 +80,7 @@ class report_event_registration(osv.osv): LEFT JOIN event_registration r ON (e.id=r.event_id) + where r.id is not null GROUP BY event_id, From f7528e87bbb02dd3dc3fa247a620a20873b96048 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Wed, 10 Oct 2012 18:36:25 +0200 Subject: [PATCH 2/6] [IMP] code style bzr revid: abo@openerp.com-20121010163625-ybklx8alceyo1qaa --- .../event/report/report_event_registration.py | 45 ++++++++++--------- .../report/report_event_registration_view.xml | 20 ++++----- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index 31a71774835..7fbcfa8bcf4 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -23,16 +23,16 @@ from osv import fields, osv import tools class report_event_registration(osv.osv): - _name = "report.event.registration" _description = "Events Analysis" _auto = False _columns = { 'event_date': fields.char('Event Start Date', size=64, readonly=True), 'year': fields.char('Year', size=4, readonly=True), - 'month': fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), - ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), - ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + 'month': fields.selection([ + ('01','January'), ('02','February'), ('03','March'), ('04','April'), + ('05','May'), ('06','June'), ('07','July'), ('08','August'), + ('09','September'), ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), 'event_id': fields.many2one('event.event', 'Event', required=True), 'draft_state': fields.integer(' # No of Draft Registrations', size=20), 'confirm_state': fields.integer(' # No of Confirmed Registrations', size=20), @@ -48,15 +48,14 @@ class report_event_registration(osv.osv): 'company_id': fields.many2one('res.company', 'Company', readonly=True), } _order = 'event_date desc' + def init(self, cr): """ - initialize the sql view for the event registration - cr -- the cursor + Initialize the sql view for the event registration """ tools.drop_view_if_exists(cr, 'report_event_registration') - cr.execute(""" - CREATE OR REPLACE view report_event_registration AS ( - SELECT + cr.execute(""" CREATE OR REPLACE view report_event_registration AS ( + SELECT event_id, r.id, e.user_id AS user_id, @@ -72,24 +71,29 @@ class report_event_registration(osv.osv): CASE WHEN r.state IN ('open','done') THEN r.nb_register ELSE 0 END AS confirm_state, e.type AS event_type, e.register_max AS register_max, - e.state AS event_state, - r.state AS registration_state - FROM + e.state AS event_state, + r.state AS registration_state + FROM event_event e + LEFT JOIN event_registration r ON (e.id=r.event_id) - LEFT JOIN - event_registration r ON (e.id=r.event_id) - where r.id is not null + WHERE r.id IS NOT NULL - GROUP BY + GROUP BY event_id, user_id_registration, e.id, r.id, registration_state, r.nb_register, - event_type, e.id, e.date_begin, e.main_speaker_id, - e.register_max,event_id, e.user_id,e.company_id, + event_type, + e.id, + e.date_begin, + e.main_speaker_id, + e.register_max, + event_id, + e.user_id, + e.company_id, e.user_id, event_state, e.company_id, @@ -98,9 +102,8 @@ class report_event_registration(osv.osv): month, e.register_max, name_registration - - ) - """) + ) + """) report_event_registration() diff --git a/addons/event/report/report_event_registration_view.xml b/addons/event/report/report_event_registration_view.xml index f39b6aecfe7..7761c970b59 100644 --- a/addons/event/report/report_event_registration_view.xml +++ b/addons/event/report/report_event_registration_view.xml @@ -1,8 +1,8 @@ - + - + report.event.registration.tree report.event.registration @@ -28,7 +28,6 @@ - report.event.registration.graph report.event.registration @@ -42,8 +41,7 @@ - - + report.event.registration.search report.event.registration @@ -82,28 +80,28 @@ - + Events Analysis report.event.registration form tree,graph - {"search_default_year":1,"search_default_this_month":1,"search_default_365day":1, "search_default_invoiced":1, "search_default_event":1, 'group_by_no_leaf':1, 'group_by':[]} + {"search_default_year":1,"search_default_this_month":1,"search_default_365day":1, "search_default_invoiced":1, "search_default_event":1, "group_by_no_leaf":1, "group_by":[]} - + tree - + - + graph - + From 79e52172f489452b453e5798478bfb1b0e7d7016 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Wed, 10 Oct 2012 18:40:16 +0200 Subject: [PATCH 3/6] [IMP] remove duplicated fields from the GROUP BY statement bzr revid: abo@openerp.com-20121010164016-7s3y43yubhwc5g1w --- addons/event/report/report_event_registration.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index 7fbcfa8bcf4..e3fc7bdc803 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -82,18 +82,12 @@ class report_event_registration(osv.osv): GROUP BY event_id, user_id_registration, - e.id, r.id, registration_state, r.nb_register, event_type, e.id, e.date_begin, - e.main_speaker_id, - e.register_max, - event_id, - e.user_id, - e.company_id, e.user_id, event_state, e.company_id, From 4079c1e4b4813dcddebb0934713a109996171771 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Wed, 10 Oct 2012 18:45:23 +0200 Subject: [PATCH 4/6] [IMP] add a tofix in the comments bzr revid: abo@openerp.com-20121010164523-hl70trg3txylev93 --- addons/event/report/report_event_registration.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index e3fc7bdc803..eae2931fcdc 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -54,6 +54,8 @@ class report_event_registration(osv.osv): Initialize the sql view for the event registration """ tools.drop_view_if_exists(cr, 'report_event_registration') + + # TOFIX this request won't select events that have no registration cr.execute(""" CREATE OR REPLACE view report_event_registration AS ( SELECT event_id, From 90ff5bf65a0e2e7bc18e45d1b0bd23e8e66b1f76 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 11 Oct 2012 15:58:09 +0200 Subject: [PATCH 5/6] [IMP] properly fetch events that have no registration in order to achieve that, remove the previous patch which was too exclusive (WHERE r.id IS NOT NULL) and use 'virtual' ids instead the unicity is guaranteed by concatenating the event id and the registration id (if any) bzr revid: abo@openerp.com-20121011135809-fag9br23hthrwy1s --- addons/event/report/report_event_registration.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index eae2931fcdc..042676d0c32 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -56,10 +56,10 @@ class report_event_registration(osv.osv): tools.drop_view_if_exists(cr, 'report_event_registration') # TOFIX this request won't select events that have no registration - cr.execute(""" CREATE OR REPLACE view report_event_registration AS ( + cr.execute(""" CREATE VIEW report_event_registration AS ( SELECT - event_id, - r.id, + e.id::char || '/' || coalesce(r.id::char,'') AS id, + e.id AS event_id, e.user_id AS user_id, r.user_id AS user_id_registration, r.name AS name_registration, @@ -79,8 +79,6 @@ class report_event_registration(osv.osv): event_event e LEFT JOIN event_registration r ON (e.id=r.event_id) - WHERE r.id IS NOT NULL - GROUP BY event_id, user_id_registration, From b54b785266f5412fa8bcc52fb7e20bf190eedd29 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 11 Oct 2012 16:04:30 +0200 Subject: [PATCH 6/6] [IMP] make sure that the view is properly dropped before we re-create it the REPLACE VIEW statement can generate type conflicts in case where the view's data types change between two updates bzr revid: abo@openerp.com-20121011140430-0wgo70snzjhuxpyr --- addons/project/project.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/project/project.py b/addons/project/project.py index 4f1d2826980..58431ffd061 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -1426,7 +1426,9 @@ class project_task_history_cumulative(osv.osv): } def init(self, cr): - cr.execute(""" CREATE OR REPLACE VIEW project_task_history_cumulative AS ( + tools.drop_view_if_exists(cr, 'report_event_registration') + + cr.execute(""" CREATE VIEW project_task_history_cumulative AS ( SELECT history.date::varchar||'-'||history.history_id::varchar AS id, history.date AS end_date,