[IMP]GOLEM : store is_default for members and activities

This commit is contained in:
Fabien BOURGEOIS 2019-07-29 18:17:25 +02:00
parent cd2afd3b22
commit 481ca0994d
7 changed files with 46 additions and 35 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016-2018 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -19,7 +19,7 @@
'name': 'GOLEM activities', 'name': 'GOLEM activities',
'summary': 'Extends Odoo products for multi-activity', 'summary': 'Extends Odoo products for multi-activity',
'description': 'Extends Odoo products for multi-activity', 'description': 'Extends Odoo products for multi-activity',
'version': '10.0.2.7.0', 'version': '10.0.2.8.0',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois, Michel Dessenne', 'author': 'Fabien Bourgeois, Michel Dessenne',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2016-2019 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -15,4 +15,4 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import golem_activity from . import golem_activity, golem_season

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- 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 # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -105,8 +105,7 @@ class GolemActivity(models.Model):
index=True, auto_join=True, index=True, auto_join=True,
ondelete='restrict') ondelete='restrict')
is_default = fields.Boolean('Default season?', is_default = fields.Boolean('Default season?',
compute='_compute_is_default', compute='_compute_is_default', store=True)
search='_search_is_default')
@api.depends('season_id') @api.depends('season_id')
def _compute_is_default(self): def _compute_is_default(self):
@ -115,18 +114,6 @@ class GolemActivity(models.Model):
for activity in self: for activity in self:
activity.is_default = (default_season == activity.season_id) activity.is_default = (default_season == activity.season_id)
@api.multi
def _search_is_default(self, operator, value):
""" Search function for is default """
if operator in ('in', '='):
operator = '=' if value else '!='
elif operator in ('not in', '!='):
operator = '!=' if value else '='
else:
err = _('Unsupported operator for defautl season search')
raise NotImplementedError(err)
return [('season_id', operator, self.default_season().id)]
animator_id = fields.Many2one('res.partner', string='Animator', animator_id = fields.Many2one('res.partner', string='Animator',
index=True, auto_join=True, index=True, auto_join=True,
domain=[('is_company', '=', False)]) domain=[('is_company', '=', False)])

View File

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 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
# 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 Season adaptations """
from odoo import models, api
class GolemSeason(models.Model):
""" GOLEM Season adaptations """
_inherit = 'golem.season'
@api.multi
def do_default_season(self):
""" Regenerates is_default when season changes """
self.ensure_one()
res = super(GolemSeason, self).do_default_season()
all_activities = self.env['golem.activity'].search([])
all_activities._compute_is_default()
return res

View File

@ -21,7 +21,7 @@
'name': 'GOLEM non-profit members', 'name': 'GOLEM non-profit members',
'summary': 'Extends Odoo contacts for MJC', 'summary': 'Extends Odoo contacts for MJC',
'description': 'Extends Odoo contacts for MJC', 'description': 'Extends Odoo contacts for MJC',
'version': '10.0.2.7.3', 'version': '10.0.2.8.0',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois, Michel Dessenne', 'author': 'Fabien Bourgeois, Michel Dessenne',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -222,8 +222,7 @@ class GolemMember(models.Model):
required=True, default=default_season, required=True, default=default_season,
auto_join=True, ondelete='restrict') auto_join=True, ondelete='restrict')
is_default = fields.Boolean('Default season?', is_default = fields.Boolean('Default season?',
compute='_compute_is_default', compute='_compute_is_default', store=True)
search='_search_is_default')
is_number_manual = fields.Boolean('Is number manual?', store=False, is_number_manual = fields.Boolean('Is number manual?', store=False,
compute='_compute_is_number_manual') compute='_compute_is_number_manual')
@ -255,18 +254,6 @@ class GolemMember(models.Model):
for member in self: for member in self:
member.is_default = default_s in member.season_ids member.is_default = default_s in member.season_ids
@api.multi
def _search_is_default(self, operator, value):
""" Search function for is default """
if operator in ('in', '='):
operator = '=' if value else '!='
elif operator in ('not in', '!='):
operator = '!=' if value else '='
else:
err = _('Unsupported operator for defautl season search')
raise NotImplementedError(err)
return [('season_ids', operator, self.default_season().id)]
@api.depends('number') @api.depends('number')
def _compute_is_number_manual(self): def _compute_is_number_manual(self):
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2018-2019 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -30,6 +30,9 @@ class GolemSeason(models.Model):
self.ensure_one() self.ensure_one()
res = super(GolemSeason, self).do_default_season() res = super(GolemSeason, self).do_default_season()
all_members = self.env['golem.member'].search([]) all_members = self.env['golem.member'].search([])
# Recompute is_default
all_members._compute_is_default()
# Regenerate number
conf = self.env['ir.config_parameter'] conf = self.env['ir.config_parameter']
if conf.get_param('golem_numberconfig_isautomatic') == '1' and \ if conf.get_param('golem_numberconfig_isautomatic') == '1' and \
conf.get_param('golem_numberconfig_isperseason') == '1': conf.get_param('golem_numberconfig_isperseason') == '1':