diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index 7820343..2a02b1e 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -15,7 +15,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from openerp import models, fields, api, _ +from openerp import models, fields, _ class ResPartner(models.Model): @@ -39,14 +39,3 @@ class GolemMember(models.Model): number = fields.Char('Number', size=50, index=True) pictures_agreement = fields.Boolean('Pictures agreement?') opt_out_sms = fields.Boolean('Out of SMS campaigns') - season_ids = fields.Many2many('golem.season', string='Seasons') - is_current = fields.Boolean('Current user?', store=True, default=False, - compute='_compute_is_current') - - @api.depends('season_ids') - def _compute_is_current(self): - """ Checks if member is active for current season """ - domain = [('is_default', '=', True)] - default_season = self.env['golem.season'].search(domain) - for member in self: - member.is_current = default_season in member.season_ids diff --git a/golem_member/views/golem_member_view.xml b/golem_member/views/golem_member_view.xml index 9943e7f..1223c49 100644 --- a/golem_member/views/golem_member_view.xml +++ b/golem_member/views/golem_member_view.xml @@ -34,9 +34,6 @@ along with this program. If not, see . - - - @@ -126,15 +123,12 @@ along with this program. If not, see . - - @@ -162,8 +156,7 @@ along with this program. If not, see . + view_mode="kanban,tree,form,graph" /> kanban diff --git a/golem_member_season/__init__.py b/golem_member_season/__init__.py new file mode 100644 index 0000000..2fca3d2 --- /dev/null +++ b/golem_member_season/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 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 . + +from . import models diff --git a/golem_member_season/__openerp__.py b/golem_member_season/__openerp__.py new file mode 100644 index 0000000..9688ee6 --- /dev/null +++ b/golem_member_season/__openerp__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 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 . + +{ + 'name': 'GOLEM members seasons', + 'summary': 'GOLEM non-profit members seasons glue code', + 'description': ''' Link between GOLEM members and seasons, with + management of number code linked to season ''', + 'version': '0.1', + 'category': 'Non-profit management', + 'author': 'Fabien Bourgeois', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'auto_install': True, + 'depends': ['golem_member', 'golem_season'], + 'data': ['views/golem_member_season_view.xml'] +} diff --git a/golem_member_season/models/__init__.py b/golem_member_season/models/__init__.py new file mode 100644 index 0000000..ea7d215 --- /dev/null +++ b/golem_member_season/models/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 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 . + +from . import golem_member_season diff --git a/golem_member_season/models/golem_member_season.py b/golem_member_season/models/golem_member_season.py new file mode 100644 index 0000000..c87d30f --- /dev/null +++ b/golem_member_season/models/golem_member_season.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 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 . + +from openerp import models, fields, api + + +class GolemMember(models.Model): + _inherit = 'golem.member' + + season_ids = fields.Many2many('golem.season', string='Seasons') + is_current = fields.Boolean('Current user?', store=True, default=False, + compute='_compute_is_current') + + @api.depends('season_ids') + def _compute_is_current(self): + """ Checks if member is active for current season """ + domain = [('is_default', '=', True)] + default_season = self.env['golem.season'].search(domain) + for member in self: + member.is_current = default_season in member.season_ids + + +class GolemSeason(models.Model): + + @api.multi + def write(self, values): + """ Extends write to recomputes all current members in case of + is_default changes and ensures that only one is_default is active """ + is_new_default = values.get('is_default') + old_default_season = self.search([('is_default', '=', True)]) + res = super(GolemSeason, self).write(values) + if is_new_default: + if old_default_season: + old_default_season.is_default = False + self.env['golem.member'].search([])._compute_is_current() + self.env['golem.activity'].search([])._compute_is_current() + return res diff --git a/golem_member_season/views/golem_member_season_view.xml b/golem_member_season/views/golem_member_season_view.xml new file mode 100644 index 0000000..a4e7460 --- /dev/null +++ b/golem_member_season/views/golem_member_season_view.xml @@ -0,0 +1,67 @@ + + + + + + + + + + Add season at top of GOLEM member form + golem.member + + +
+ + + + +
+
+
+ + + + Add Seasons Search and Filter + golem.member + + + + + + + + + + + + + + + + + +
+
diff --git a/golem_season/models/golem_season.py b/golem_season/models/golem_season.py index 57aff77..0c54e8a 100644 --- a/golem_season/models/golem_season.py +++ b/golem_season/models/golem_season.py @@ -52,17 +52,3 @@ class GolemSeason(models.Model): msg = _('Period {} cannot be included into current ' 'period'.format(s.name)) raise models.ValidationError(msg) - - @api.multi - def write(self, values): - """ Extends write to recomputes all current members in case of - is_default changes and ensures that only one is_default is active """ - is_new_default = values.get('is_default') - old_default_season = self.search([('is_default', '=', True)]) - res = super(GolemSeason, self).write(values) - if is_new_default: - if old_default_season: - old_default_season.is_default = False - self.env['golem.member'].search([])._compute_is_current() - self.env['golem.activity'].search([])._compute_is_current() - return res