diff --git a/golem_activity/__manifest__.py b/golem_activity/__manifest__.py index 5cc07e0..af0e1d0 100644 --- a/golem_activity/__manifest__.py +++ b/golem_activity/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016-2018 Fabien Bourgeois +# Copyright 2016-2019 Fabien Bourgeois # # 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 activities', 'summary': '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', 'author': 'Fabien Bourgeois, Michel Dessenne', 'license': 'AGPL-3', diff --git a/golem_activity/models/__init__.py b/golem_activity/models/__init__.py index 6b474dc..c67a9a9 100644 --- a/golem_activity/models/__init__.py +++ b/golem_activity/models/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2016-2019 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # 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 # along with this program. If not, see . -from . import golem_activity +from . import golem_activity, golem_season diff --git a/golem_activity/models/golem_activity.py b/golem_activity/models/golem_activity.py index fa5407f..8c674dc 100644 --- a/golem_activity/models/golem_activity.py +++ b/golem_activity/models/golem_activity.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2017-2018 Fabien Bourgeois +# Copyright 2017-2019 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # 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, ondelete='restrict') is_default = fields.Boolean('Default season?', - compute='_compute_is_default', - search='_search_is_default') + compute='_compute_is_default', store=True) @api.depends('season_id') def _compute_is_default(self): @@ -115,18 +114,6 @@ class GolemActivity(models.Model): for activity in self: 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', index=True, auto_join=True, domain=[('is_company', '=', False)]) diff --git a/golem_activity/models/golem_season.py b/golem_activity/models/golem_season.py new file mode 100644 index 0000000..795c061 --- /dev/null +++ b/golem_activity/models/golem_season.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +# Copyright 2019 Fabien Bourgeois +# +# 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 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 diff --git a/golem_member/__manifest__.py b/golem_member/__manifest__.py index 32e4374..3f00ea7 100644 --- a/golem_member/__manifest__.py +++ b/golem_member/__manifest__.py @@ -21,7 +21,7 @@ 'name': 'GOLEM non-profit members', 'summary': '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', 'author': 'Fabien Bourgeois, Michel Dessenne', 'license': 'AGPL-3', diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index 706bec2..46714f8 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -222,8 +222,7 @@ class GolemMember(models.Model): required=True, default=default_season, auto_join=True, ondelete='restrict') is_default = fields.Boolean('Default season?', - compute='_compute_is_default', - search='_search_is_default') + compute='_compute_is_default', store=True) is_number_manual = fields.Boolean('Is number manual?', store=False, compute='_compute_is_number_manual') @@ -255,18 +254,6 @@ class GolemMember(models.Model): for member in self: 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') def _compute_is_number_manual(self): conf = self.env['ir.config_parameter'] diff --git a/golem_member/models/golem_season.py b/golem_member/models/golem_season.py index 83e9609..8662533 100644 --- a/golem_member/models/golem_season.py +++ b/golem_member/models/golem_season.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Fabien Bourgeois +# Copyright 2018-2019 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -30,6 +30,9 @@ class GolemSeason(models.Model): self.ensure_one() res = super(GolemSeason, self).do_default_season() all_members = self.env['golem.member'].search([]) + # Recompute is_default + all_members._compute_is_default() + # Regenerate number conf = self.env['ir.config_parameter'] if conf.get_param('golem_numberconfig_isautomatic') == '1' and \ conf.get_param('golem_numberconfig_isperseason') == '1':