From 6e81fd302643b8be638f220d8e1ef77d448d693d Mon Sep 17 00:00:00 2001 From: Youssef ELOUAHBY Date: Mon, 14 Jan 2019 14:48:00 +0100 Subject: [PATCH] [Analyses pour la ville] take into account only confirmed registration --- golem_activity_registration_state/__init__.py | 2 +- .../wizard/__init__.py | 19 ++++++ ...m_activity_registration_analysis_wizard.py | 58 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 golem_activity_registration_state/wizard/__init__.py create mode 100644 golem_activity_registration_state/wizard/golem_activity_registration_analysis_wizard.py diff --git a/golem_activity_registration_state/__init__.py b/golem_activity_registration_state/__init__.py index 25f14d6..e460319 100644 --- a/golem_activity_registration_state/__init__.py +++ b/golem_activity_registration_state/__init__.py @@ -15,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import models +from . import models, wizard diff --git a/golem_activity_registration_state/wizard/__init__.py b/golem_activity_registration_state/wizard/__init__.py new file mode 100644 index 0000000..de779b4 --- /dev/null +++ b/golem_activity_registration_state/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 diff --git a/golem_activity_registration_state/wizard/golem_activity_registration_analysis_wizard.py b/golem_activity_registration_state/wizard/golem_activity_registration_analysis_wizard.py new file mode 100644 index 0000000..98d47d5 --- /dev/null +++ b/golem_activity_registration_state/wizard/golem_activity_registration_analysis_wizard.py @@ -0,0 +1,58 @@ +# -*- 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 Adaptation """ + +import logging +from odoo import models, fields, api, _ +_LOGGER = logging.getLogger(__name__) + + +class GolemActivityRegistrationAnalysisWizard(models.TransientModel): + """ GOLEM Activity Registration Analysis Wizard Adaptation """ + _inherit = 'golem.activity.registration.analysis.wizard' + _description = 'GOLEM Activity Registration Analysis Wizard Adaptation ' + + @api.multi + def registration_analye(self): + """ registration analyse """ + self.ensure_one() + analysis_rec = self[0] + registrations = self.env['golem.activity.registration'].search( + [('season_id', '=', analysis_rec.season_id.id), + ('state', '=', 'confirmed')] + ) + 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', + }