forked from Yaltik/golem
[MIG][IMP]GOLEM member minor migration to v10, and better guidelines
This commit is contained in:
parent
756017a697
commit
4072ae829e
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017 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
|
||||
@ -15,4 +15,4 @@
|
||||
# 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
|
||||
from . import models
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017 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
|
||||
@ -23,7 +23,7 @@
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
'depends': ['golem_member'],
|
||||
'data': ['golem_member_view.xml']
|
||||
'data': ['views/golem_member_views.xml']
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-07-20 16:50+0000\n"
|
||||
"PO-Revision-Date: 2016-07-20 16:50+0000\n"
|
||||
"POT-Creation-Date: 2017-05-01 20:16+0000\n"
|
||||
"PO-Revision-Date: 2017-05-01 20:16+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -17,7 +17,7 @@ msgstr ""
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,activities_participation:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_activities_participation
|
||||
msgid "Activities participation?"
|
||||
msgstr "Participation aux activités?"
|
||||
|
||||
@ -27,32 +27,27 @@ msgid "GOLEM Member"
|
||||
msgstr "GOLEM : Adhérent"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
msgid "Group By"
|
||||
msgstr "Grouper par"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor
|
||||
msgid "Is adult"
|
||||
msgstr "Est adulte"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor
|
||||
msgid "Is minor"
|
||||
msgstr "Est mineur"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,is_minor:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_is_minor
|
||||
msgid "Is minor?"
|
||||
msgstr "Est mineur?"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,legal_guardian_ids:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_legal_guardian_ids
|
||||
msgid "Legal guardians"
|
||||
msgstr "Représentants légaux"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_form
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_form_inherit_minor
|
||||
msgid "Minor"
|
||||
msgstr "Mineur"
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-07-20 16:49+0000\n"
|
||||
"PO-Revision-Date: 2016-07-20 16:49+0000\n"
|
||||
"POT-Creation-Date: 2017-05-01 20:16+0000\n"
|
||||
"PO-Revision-Date: 2017-05-01 20:16+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -16,7 +16,7 @@ msgstr ""
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,activities_participation:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_activities_participation
|
||||
msgid "Activities participation?"
|
||||
msgstr ""
|
||||
|
||||
@ -26,32 +26,27 @@ msgid "GOLEM Member"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
msgid "Group By"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor
|
||||
msgid "Is adult"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_search
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor
|
||||
msgid "Is minor"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,is_minor:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_is_minor
|
||||
msgid "Is minor?"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: field:golem.member,legal_guardian_ids:0
|
||||
#: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_legal_guardian_ids
|
||||
msgid "Legal guardians"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_member_minor
|
||||
#: view:golem.member:golem_member_minor.minor_add_form
|
||||
#: model:ir.ui.view,arch_db:golem_member_minor.golem_member_form_inherit_minor
|
||||
msgid "Minor"
|
||||
msgstr ""
|
||||
|
||||
|
18
golem_member_minor/models/__init__.py
Normal file
18
golem_member_minor/models/__init__.py
Normal file
@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2017 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
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017 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
|
||||
@ -15,28 +15,29 @@
|
||||
# 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 Member Minor management """
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class GolemMember(models.Model):
|
||||
""" GOLEM Member adaptations """
|
||||
_inherit = 'golem.member'
|
||||
|
||||
ADULT_DURATION = timedelta(days=365*18)
|
||||
legal_guardian_ids = fields.Many2many('res.partner',
|
||||
string='Legal guardians',
|
||||
domain="['&', "
|
||||
"('is_company', '=', False), "
|
||||
"('id', '!=', partner_id)]")
|
||||
legal_guardian_ids = fields.Many2many(
|
||||
'res.partner', string='Legal guardians', index=True,
|
||||
domain="['&', ('is_company', '=', False), ('id', '!=', partner_id)]")
|
||||
activities_participation = fields.Boolean('Activities participation?')
|
||||
is_minor = fields.Boolean('Is minor?', compute='_compute_is_minor',
|
||||
store=True, default=False)
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
@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))
|
||||
for member in self:
|
||||
if member.birthdate_date:
|
||||
member.is_minor = ((datetime.now() - self.ADULT_DURATION) <
|
||||
fields.Datetime.from_string(member.birthdate_date))
|
||||
else:
|
||||
self.is_minor = False
|
||||
member.is_minor = False
|
||||
|
@ -15,10 +15,12 @@
|
||||
# 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 Member Minor tests """
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class GolemMemberMinorTestCase(TransactionCase):
|
||||
""" GOLEM Member Minor tests """
|
||||
|
||||
def setUp(self):
|
||||
super(GolemMemberMinorTestCase, self).setUp()
|
||||
@ -28,10 +30,10 @@ class GolemMemberMinorTestCase(TransactionCase):
|
||||
|
||||
def test_member_minor(self):
|
||||
""" Test minor computing """
|
||||
m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Joe'})
|
||||
self.assertFalse(m.is_minor)
|
||||
m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Bob',
|
||||
new_m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Joe'})
|
||||
self.assertFalse(new_m.is_minor)
|
||||
new_m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Bob',
|
||||
'birthdate_date': '1990-01-01'})
|
||||
self.assertFalse(m.is_minor)
|
||||
m.write({'birthdate_date': '2015-01-01'})
|
||||
self.assertTrue(m.is_minor)
|
||||
self.assertFalse(new_m.is_minor)
|
||||
new_m.write({'birthdate_date': '2015-01-01'})
|
||||
self.assertTrue(new_m.is_minor)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
Copyright 2017 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
|
||||
@ -21,14 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<data>
|
||||
|
||||
<!-- Form -->
|
||||
<record model="ir.ui.view" id="minor_add_form">
|
||||
<record model="ir.ui.view" id="golem_member_form_inherit_minor">
|
||||
<field name="name">Add Minor Page/Tab</field>
|
||||
<field name="model">golem.member</field>
|
||||
<field name="inherit_id" ref="golem_member.view_form" />
|
||||
<field name="inherit_id" ref="golem_member.golem_member_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)]}">
|
||||
@ -52,17 +50,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</record>
|
||||
|
||||
<!-- Search -->
|
||||
<record model="ir.ui.view" id="minor_add_search">
|
||||
<record model="ir.ui.view" id="golem_member_search_inherit_minor">
|
||||
<field name="name">Add Minor/Adult filters</field>
|
||||
<field name="model">golem.member</field>
|
||||
<field name="inherit_id" ref="golem_member.view_filter" />
|
||||
<field name="inherit_id" ref="golem_member.golem_member_search" />
|
||||
<field name="arch" type="xml">
|
||||
<group string="Group By" position="before">
|
||||
<filter name="season_default" position="after">
|
||||
<filter name="filter_is_minor" string="Is minor"
|
||||
domain="[('is_minor', '=', True)]"/>
|
||||
<filter name="filter_is_adult" string="Is adult"
|
||||
domain="[('is_minor', '!=', True)]"/>
|
||||
</group>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user