[REF][IMP]GOLEM analysis : add flexibility

* On get members ;
* On get registrations and use it for state addon.
This commit is contained in:
Fabien BOURGEOIS 2019-01-21 12:20:36 +01:00
parent 1c3f10ad0a
commit 4898a0d93d
4 changed files with 26 additions and 35 deletions

View File

@ -65,14 +65,21 @@ class GolemActivityRegistrationAnalysisWizard(models.TransientModel):
'golem_member_analysis_pivot_age_now_activity_area')
return self.env.ref(ref, False)
@api.multi
def get_registrations(self):
""" Returns registrations """
self.ensure_one()
return self.env['golem.activity.registration'].search(
[('season_id', '=', self[0].season_id.id)]
)
@api.multi
def registration_analyse(self):
""" registration analyse """
self.ensure_one()
analysis_rec = self[0]
registrations = self.env['golem.activity.registration'].search(
[('season_id', '=', analysis_rec.season_id.id)]
)
registrations = analysis_rec.get_registrations()
if registrations:
for registration in registrations:
self.env['golem.member.analysis'].create({

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2017-2019 Fabien Bourgeois <fabien@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
@ -19,7 +19,7 @@
'name': 'GOLEM Activity Session Member Registrations States',
'summary': 'GOLEM Activities Session Member Registration states',
'description': 'GOLEM Activities Session Member Registration states',
'version': '10.0.2.2.1',
'version': '10.0.2.3.0',
'category': 'GOLEM',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',

View File

@ -18,9 +18,7 @@
""" GOLEM Activity Registration Analysis Wizard Adaptation """
import logging
from odoo import models, fields, api, _
_LOGGER = logging.getLogger(__name__)
from odoo import models, fields, api
class GolemActivityRegistrationAnalysisWizard(models.TransientModel):
@ -29,30 +27,10 @@ class GolemActivityRegistrationAnalysisWizard(models.TransientModel):
_description = 'GOLEM Activity Registration Analysis Wizard Adaptation '
@api.multi
def registration_analye(self):
""" registration analyse """
def get_registrations(self):
""" Returns registrations """
self.ensure_one()
analysis_rec = self[0]
registrations = self.env['golem.activity.registration'].search(
[('season_id', '=', analysis_rec.season_id.id),
return self.env['golem.activity.registration'].search(
[('season_id', '=', self[0].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',
}
)

View File

@ -78,14 +78,20 @@ class GolemMemberAnalysis(models.TransientModel):
return self.env.ref(ref, False)
@api.multi
def get_members(self):
""" Returns members """
self.ensure_one()
return self.env['golem.member'].search([]).filtered(
lambda m: self[0].season_id.id in m.season_ids.ids)
@api.multi
def members_analyse(self):
""" members analyse """
self.ensure_one()
analysis_rec = self[0]
members = self.env['golem.member'].search([]).filtered(
lambda m: analysis_rec.season_id.id in m.season_ids.ids)
members = analysis_rec.get_members()
if members:
for member in members:
self.env['golem.member.analysis'].create({