From 56a48a311d9f88f9e20d8a9bd015a374114a9f35 Mon Sep 17 00:00:00 2001 From: Youssef ELOUAHBY Date: Mon, 14 Jan 2019 11:49:11 +0100 Subject: [PATCH] [Analyses pour la ville] Add Analyse by age area and activity --- .../wizard/__init__.py | 19 +++++ ...m_activity_registration_analysis_wizard.py | 79 +++++++++++++++++++ ...ity_registration_analysis_wizard_views.xml | 56 +++++++++++++ .../wizard/golem_member_analysis.py | 38 +++++++++ .../wizard/golem_member_analysis_views.xml | 47 +++++++++++ 5 files changed, 239 insertions(+) create mode 100644 golem_activity_registration/wizard/__init__.py create mode 100644 golem_activity_registration/wizard/golem_activity_registration_analysis_wizard.py create mode 100644 golem_activity_registration/wizard/golem_activity_registration_analysis_wizard_views.xml create mode 100644 golem_activity_registration/wizard/golem_member_analysis.py create mode 100644 golem_activity_registration/wizard/golem_member_analysis_views.xml diff --git a/golem_activity_registration/wizard/__init__.py b/golem_activity_registration/wizard/__init__.py new file mode 100644 index 0000000..6a8e2ae --- /dev/null +++ b/golem_activity_registration/wizard/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Fabien Bourgeois +# Copyright 2019 Youssef El Ouahby +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_activity_registration_analysis_wizard, golem_member_analysis diff --git a/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard.py b/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard.py new file mode 100644 index 0000000..de6991e --- /dev/null +++ b/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Fabien Bourgeois +# Copyright 2019 Youssef El Ouahby +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Activity Registration Analysis Wizard Management """ + +import logging +from odoo import models, fields, api, _ +from odoo.exceptions import UserError, ValidationError +_LOGGER = logging.getLogger(__name__) + + +class GolemActivityRegistrationAnalysisWizard(models.TransientModel): + """ GOLEM Activity Registration Analysis Wizard Management """ + _name = 'golem.activity.registration.analysis.wizard' + _description = 'GOLEM Activity Registration Analysis Wizard Management ' + + season_id = fields.Many2one('golem.season', 'Season', required=True) + analyse_type = fields.Selection( + [ + ('age_start_activity_area', 'By age at season start and area and activity'), + ('age_end_activity_area', 'By age at season end and area and activity') + ], + required=True) + + @api.multi + def get_pivot_view(self): + self.ensure_one() + rec = self[0] + if rec.analyse_type == 'age_start_activity_area': + return self.env.ref( + 'golem_activity_registration.golem_member_analysis_pivot_age_start_activity_area', + False) + elif rec.analyse_type == 'age_end_activity_area': + return self.env.ref( + 'golem_activity_registration.golem_member_analysis_pivot_age_end_activity_area', + False) + + + @api.multi + def registration_analye(self): + self.ensure_one() + analysis_rec = self[0] + registrations = self.env['golem.activity.registration'].search( + [('season_id', '=', analysis_rec.season_id.id)] + ) + self.env['golem.member.analysis'].search([]).unlink() + if registrations: + for registration in registrations: + self.env['golem.member.analysis'].create({ + 'season_id': analysis_rec.season_id.id, + 'member_id': registration.member_id.id, + 'activity_id': registration.activity_id.id + }) + analyse_pivot = analysis_rec.get_pivot_view() + return { + 'name': _('Member Analysis'), + 'type': 'ir.actions.act_window', + 'res_model': 'golem.member.analysis', + 'view_type': 'pivot', + 'view_mode': 'pivot', + #'views': [(analyse_pivot.id, 'form')], + 'view_id': analyse_pivot.id, + 'target': 'new', + } diff --git a/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard_views.xml b/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard_views.xml new file mode 100644 index 0000000..8ea56ee --- /dev/null +++ b/golem_activity_registration/wizard/golem_activity_registration_analysis_wizard_views.xml @@ -0,0 +1,56 @@ + + + + + + + + + GOLEM Activity Registration Analyse Wizard Form + golem.activity.registration.analysis.wizard + +
+ + + + + +
+
+
+ +
+
+
+ + + + + + +
+
diff --git a/golem_activity_registration/wizard/golem_member_analysis.py b/golem_activity_registration/wizard/golem_member_analysis.py new file mode 100644 index 0000000..afdf5bf --- /dev/null +++ b/golem_activity_registration/wizard/golem_member_analysis.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Fabien Bourgeois +# Copyright 2019 Youssef El Ouahby +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Members Analysis Adaptation """ + +import logging +from odoo import models, fields, api, _ +from odoo.exceptions import UserError, ValidationError +from dateutil.relativedelta import relativedelta +_LOGGER = logging.getLogger(__name__) + +def get_root_category(category_id): + """ Get Root Category """ + if not category_id.parent_id: + return category_id + return get_root_category(category_id.parent_id) + +class GolemMemberAnalysis(models.TransientModel): + """ GOLEM Member Analysis Adaptation """ + _inherit = 'golem.member.analysis' + _description = 'GOLEM Member Analysis Adaptation' + + activity_id = fields.Many2one('golem.activity') diff --git a/golem_activity_registration/wizard/golem_member_analysis_views.xml b/golem_activity_registration/wizard/golem_member_analysis_views.xml new file mode 100644 index 0000000..abb5008 --- /dev/null +++ b/golem_activity_registration/wizard/golem_member_analysis_views.xml @@ -0,0 +1,47 @@ + + + + + + + + + Golem Member Analysis Age Start Activity Area Pivot + golem.member.analysis + + + + + + + + + + Golem Member Analysis Age End Activity Area Pivot + golem.member.analysis + + + + + + + + + +