diff --git a/golem_member_minor/__init__.py b/golem_member_minor/__init__.py new file mode 100644 index 0000000..8d28962 --- /dev/null +++ b/golem_member_minor/__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 diff --git a/golem_member_minor/__openerp__.py b/golem_member_minor/__openerp__.py new file mode 100644 index 0000000..97034c5 --- /dev/null +++ b/golem_member_minor/__openerp__.py @@ -0,0 +1,30 @@ +# -*- 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 minor', + 'summary': 'GOLEM non-profit members minor management', + 'description': 'Non-profit french MJC members minor management', + 'version': '0.1', + 'category': 'Non-profit management', + 'author': 'Fabien Bourgeois', + 'license': 'AGPL-3', + 'application': True, + 'installable': True, + 'depends': ['golem_member'], + 'data': ['golem_member_view.xml'] +} diff --git a/golem_member_minor/golem_member.py b/golem_member_minor/golem_member.py new file mode 100644 index 0000000..403c596 --- /dev/null +++ b/golem_member_minor/golem_member.py @@ -0,0 +1,38 @@ +# -*- 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 datetime import datetime, timedelta +from openerp import models, fields, api + + +class GolemMember(models.Model): + _inherit = 'golem.member' + + ADULT_DURATION = timedelta(days=365*18) + legal_guardian = fields.Many2one('res.partner', 'Legal guardian') + activities_participation = fields.Boolean('Activities participation?') + is_minor = fields.Boolean('Is minor?', compute='_compute_is_minor', + store=True, default=False) + + @api.one + @api.depends('birthdate_date') + def _compute_is_minor(self): + if (self.birthdate_date): + self.is_minor = ((datetime.now() - self.ADULT_DURATION) < + fields.Datetime.from_string(self.birthdate_date)) + else: + self.is_minor = False diff --git a/golem_member_minor/golem_member_view.xml b/golem_member_minor/golem_member_view.xml new file mode 100644 index 0000000..1897e5b --- /dev/null +++ b/golem_member_minor/golem_member_view.xml @@ -0,0 +1,65 @@ + + + + + + + + + + Add Minor Page/Tab + golem.member + + + + + + + + + + + + + + + + + + + + + + + + Add Minor/Adult filters + golem.member + + + + + + + + + + +