forked from Yaltik/golem
[Analyses pour la ville] Add Analyse by age area and activity
This commit is contained in:
parent
c2e6476a2e
commit
56a48a311d
19
golem_activity_registration/wizard/__init__.py
Normal file
19
golem_activity_registration/wizard/__init__.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
# Copyright 2019 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from . import golem_activity_registration_analysis_wizard, golem_member_analysis
|
@ -0,0 +1,79 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
# Copyright 2019 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" 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',
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
Copyright 2019 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!-- Forms -->
|
||||||
|
<record model="ir.ui.view" id="golem_activity_registration_analysis_wizard_view_form">
|
||||||
|
<field name="name">GOLEM Activity Registration Analyse Wizard Form</field>
|
||||||
|
<field name="model">golem.activity.registration.analysis.wizard</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Member Analysis">
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="season_id" options="{'no_create': True}"/>
|
||||||
|
<field name="analyse_type"/>
|
||||||
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button name="registration_analye" string="Analyse Registrations" type="object"
|
||||||
|
class="oe_highlight" />
|
||||||
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
|
</footer>
|
||||||
|
</sheet>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Actions -->
|
||||||
|
<act_window id="golem_registrations_analysis_action" name="Analysis"
|
||||||
|
res_model="golem.activity.registration.analysis.wizard" view_mode="form"
|
||||||
|
target="new"/>
|
||||||
|
|
||||||
|
<menuitem id="golem_activity_registration_analysis_menu" name="Activity registrations analysis"
|
||||||
|
parent="golem_activity.golem_activity_menu"
|
||||||
|
action="golem_registrations_analysis_action"
|
||||||
|
sequence="25" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
38
golem_activity_registration/wizard/golem_member_analysis.py
Normal file
38
golem_activity_registration/wizard/golem_member_analysis.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
# Copyright 2019 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
#
|
||||||
|
# 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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" 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')
|
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright 2019 Fabien Bourgeois <fabien@yaltik.com>
|
||||||
|
Copyright 2019 Youssef El Ouahby <youssef@yaltik.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<!--pivot-->
|
||||||
|
<record id="golem_member_analysis_pivot_age_start_activity_area" model="ir.ui.view">
|
||||||
|
<field name="name">Golem Member Analysis Age Start Activity Area Pivot</field>
|
||||||
|
<field name="model">golem.member.analysis</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<pivot string="Golem Member Analysis">
|
||||||
|
<field name="age_range_start_season" type="col"/>
|
||||||
|
<field name="area_id" type="row"/>
|
||||||
|
<field name="activity_id" type="row"/>
|
||||||
|
</pivot>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="golem_member_analysis_pivot_age_end_activity_area" model="ir.ui.view">
|
||||||
|
<field name="name">Golem Member Analysis Age End Activity Area Pivot</field>
|
||||||
|
<field name="model">golem.member.analysis</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<pivot string="Golem Member Analysis">
|
||||||
|
<field name="age_range_end_season" type="col"/>
|
||||||
|
<field name="area_id" type="row"/>
|
||||||
|
<field name="activity_id" type="row"/>
|
||||||
|
</pivot>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue
Block a user