[ADD]GOLEM Member Minor module

This commit is contained in:
Fabien Bourgeois 2016-06-25 18:08:01 +02:00
parent 7a0f4249f6
commit 1852181ffb
4 changed files with 151 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2016 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/>.
from . import golem_member

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
# Copyright 2016 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/>.
{
'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']
}

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Copyright 2016 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/>.
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

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 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/>.
-->
<openerp>
<data>
<!-- Form -->
<record model="ir.ui.view" id="golem_member_view_add_minor">
<field name="name">Add Minor Page/Tab</field>
<field name="model">golem.member</field>
<field name="inherit_id" ref="golem_member.golem_member_view_form" />
<field name="arch" type="xml">
<field name="pictures_agreement" position="replace" />
</field>
<field name="arch" type="xml">
<page name="contact_details" position="after">
<page name="minor_page" string="Minor"
attrs="{'invisible': [('is_minor', '=', False)]}">
<group name="minor_group">
<group>
<field name="is_minor" invisible="True" />
<field name="legal_guardian"/>
</group>
<group>
<field name="activities_participation"/>
</group>
</group>
</page>
</page>
</field>
</record>
<!-- Search -->
<record model="ir.ui.view" id="golem_member_view_filter_add_minor">
<field name="name">Add Minor/Adult filters</field>
<field name="model">golem.member</field>
<field name="inherit_id" ref="golem_member.golem_member_view_filter" />
<field name="arch" type="xml">
<filter name="group_city" position="before">
<filter name="filter_is_minor" string="Is minor"
domain="[('is_minor', '=', True)]"/>
<filter name="filter_is_adult" string="Is adult"
domain="[('is_minor', '!=', True)]"/>
</filter>
</field>
</record>
</data>
</openerp>