[Analyses pour la ville] small improvment

This commit is contained in:
Youssef Elouahby 2019-01-14 13:13:19 +01:00
parent cfd6eca541
commit 89eb287ee1
2 changed files with 4 additions and 23 deletions

View File

@ -36,14 +36,7 @@ class GolemMemberAnalysisPivot(models.TransientModel):
_description = 'GOLEM Members Analysis Management' _description = 'GOLEM Members Analysis Management'
season_id = fields.Many2one('golem.season', required=True) season_id = fields.Many2one('golem.season', required=True)
member_id = fields.Many2one('golem.member', 'Season', required=True) member_id = fields.Many2one('golem.member', 'Season')
analyse_type = fields.Selection([('age_start_gender', 'By age at season start and gender'),
('age_end_gender', 'By age at season end and gender'),
('age_start_area', 'By age at season start and area'),
('age_end_area', 'By age at season end and area'),
('age_start_tag', 'By age at season start and tag'),
('age_end_tag', 'By age at season end and tag')],
required=True)
area_id = fields.Many2one(related='member_id.area_id', store=True) area_id = fields.Many2one(related='member_id.area_id', store=True)
gender = fields.Selection(related='member_id.gender', store=True) gender = fields.Selection(related='member_id.gender', store=True)
category_id = fields.Many2many('res.partner.category') category_id = fields.Many2many('res.partner.category')
@ -56,10 +49,7 @@ class GolemMemberAnalysisPivot(models.TransientModel):
@api.constrains('member_id') @api.constrains('member_id')
def compute_fields(self): def compute_fields(self):
for rec in self: for rec in self:
print '_-_-_-_____________-______________-_______________-___________-'
rec.category_id = get_root_category(rec.member_id.category_id) rec.category_id = get_root_category(rec.member_id.category_id)
print rec.category_id
@api.depends('member_id') @api.depends('member_id')

View File

@ -20,7 +20,6 @@
import logging import logging
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -30,7 +29,6 @@ class GolemMemberAnalysis(models.TransientModel):
_description = 'GOLEM Members Analysis Wizard Management' _description = 'GOLEM Members Analysis Wizard Management'
season_id = fields.Many2one('golem.season', 'Season', required=True) season_id = fields.Many2one('golem.season', 'Season', required=True)
#member_analysis_ids = fields.Many2many('golem.member.analysis.pivot', string='Members list')
analyse_type = fields.Selection([('age_start_gender', 'By age at season start and gender'), analyse_type = fields.Selection([('age_start_gender', 'By age at season start and gender'),
('age_end_gender', 'By age at season end and gender'), ('age_end_gender', 'By age at season end and gender'),
('age_start_area', 'By age at season start and area'), ('age_start_area', 'By age at season start and area'),
@ -43,6 +41,7 @@ class GolemMemberAnalysis(models.TransientModel):
@api.multi @api.multi
def get_pivot_view(self): def get_pivot_view(self):
""" Get pivot view """
self.ensure_one() self.ensure_one()
rec = self[0] rec = self[0]
if rec.analyse_type == 'age_start_gender': if rec.analyse_type == 'age_start_gender':
@ -61,6 +60,7 @@ class GolemMemberAnalysis(models.TransientModel):
@api.multi @api.multi
def members_analye(self): def members_analye(self):
""" members analyse """
self.ensure_one() self.ensure_one()
analysis_rec = self[0] analysis_rec = self[0]
members = self.env['golem.member'].search([]).filtered( members = self.env['golem.member'].search([]).filtered(
@ -70,8 +70,7 @@ class GolemMemberAnalysis(models.TransientModel):
for member in members: for member in members:
self.env['golem.member.analysis'].create({ self.env['golem.member.analysis'].create({
'member_id': member.id, 'member_id': member.id,
'season_id': analysis_rec.season_id.id, 'season_id': analysis_rec.season_id.id
'analyse_type': analysis_rec.analyse_type
}) })
analyse_pivot = analysis_rec.get_pivot_view() analyse_pivot = analysis_rec.get_pivot_view()
@ -85,11 +84,3 @@ class GolemMemberAnalysis(models.TransientModel):
'view_id': analyse_pivot.id, 'view_id': analyse_pivot.id,
'target': 'new', 'target': 'new',
} }
#record = self[0]
#data = {}
#data = self.read(['season_id', 'member_analysis_ids', 'analyse_type'])[0]
#_LOGGER.warning('________________________________________________________________________')
#_LOGGER.warning('analysis function')
#return self.env['report'].get_action(self, 'golem_member.golem_member_analysis_report', data=data)
#return self.env['report'].get_action(self, 'golem_resource_report.golem_reservation_report', data=data)