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 -*-
|
# -*- 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
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# 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
|
# 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/>.
|
# 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 -*-
|
# -*- 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
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# it under the terms of the GNU Affero General Public License as
|
||||||
@ -23,7 +23,7 @@
|
|||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'application': False,
|
'application': False,
|
||||||
'installable': False,
|
'installable': True,
|
||||||
'depends': ['golem_member'],
|
'depends': ['golem_member'],
|
||||||
'data': ['golem_member_view.xml']
|
'data': ['views/golem_member_views.xml']
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 8.0\n"
|
"Project-Id-Version: Odoo Server 10.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2016-07-20 16:50+0000\n"
|
"POT-Creation-Date: 2017-05-01 20:16+0000\n"
|
||||||
"PO-Revision-Date: 2016-07-20 16:50+0000\n"
|
"PO-Revision-Date: 2017-05-01 20:16+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -17,7 +17,7 @@ msgstr ""
|
|||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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?"
|
msgid "Activities participation?"
|
||||||
msgstr "Participation aux activités?"
|
msgstr "Participation aux activités?"
|
||||||
|
|
||||||
@ -27,32 +27,27 @@ msgid "GOLEM Member"
|
|||||||
msgstr "GOLEM : Adhérent"
|
msgstr "GOLEM : Adhérent"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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 "Group By"
|
|
||||||
msgstr "Grouper par"
|
|
||||||
|
|
||||||
#. module: golem_member_minor
|
|
||||||
#: view:golem.member:golem_member_minor.minor_add_search
|
|
||||||
msgid "Is adult"
|
msgid "Is adult"
|
||||||
msgstr "Est adulte"
|
msgstr "Est adulte"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Is minor"
|
||||||
msgstr "Est mineur"
|
msgstr "Est mineur"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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?"
|
msgid "Is minor?"
|
||||||
msgstr "Est mineur?"
|
msgstr "Est mineur?"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Legal guardians"
|
||||||
msgstr "Représentants légaux"
|
msgstr "Représentants légaux"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Minor"
|
||||||
msgstr "Mineur"
|
msgstr "Mineur"
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: Odoo Server 8.0\n"
|
"Project-Id-Version: Odoo Server 10.0\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2016-07-20 16:49+0000\n"
|
"POT-Creation-Date: 2017-05-01 20:16+0000\n"
|
||||||
"PO-Revision-Date: 2016-07-20 16:49+0000\n"
|
"PO-Revision-Date: 2017-05-01 20:16+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -16,7 +16,7 @@ msgstr ""
|
|||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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?"
|
msgid "Activities participation?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -26,32 +26,27 @@ msgid "GOLEM Member"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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 "Group By"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: golem_member_minor
|
|
||||||
#: view:golem.member:golem_member_minor.minor_add_search
|
|
||||||
msgid "Is adult"
|
msgid "Is adult"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Is minor"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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?"
|
msgid "Is minor?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Legal guardians"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_member_minor
|
#. 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"
|
msgid "Minor"
|
||||||
msgstr ""
|
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 -*-
|
# -*- 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
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU Affero General Public License as
|
# 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
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" GOLEM Member Minor management """
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
|
||||||
|
|
||||||
class GolemMember(models.Model):
|
class GolemMember(models.Model):
|
||||||
|
""" GOLEM Member adaptations """
|
||||||
_inherit = 'golem.member'
|
_inherit = 'golem.member'
|
||||||
|
|
||||||
ADULT_DURATION = timedelta(days=365*18)
|
ADULT_DURATION = timedelta(days=365*18)
|
||||||
legal_guardian_ids = fields.Many2many('res.partner',
|
legal_guardian_ids = fields.Many2many(
|
||||||
string='Legal guardians',
|
'res.partner', string='Legal guardians', index=True,
|
||||||
domain="['&', "
|
domain="['&', ('is_company', '=', False), ('id', '!=', partner_id)]")
|
||||||
"('is_company', '=', False), "
|
|
||||||
"('id', '!=', partner_id)]")
|
|
||||||
activities_participation = fields.Boolean('Activities participation?')
|
activities_participation = fields.Boolean('Activities participation?')
|
||||||
is_minor = fields.Boolean('Is minor?', compute='_compute_is_minor',
|
is_minor = fields.Boolean('Is minor?', compute='_compute_is_minor',
|
||||||
store=True, default=False)
|
store=True, default=False)
|
||||||
|
|
||||||
@api.one
|
@api.multi
|
||||||
@api.depends('birthdate_date')
|
@api.depends('birthdate_date')
|
||||||
def _compute_is_minor(self):
|
def _compute_is_minor(self):
|
||||||
if (self.birthdate_date):
|
for member in self:
|
||||||
self.is_minor = ((datetime.now() - self.ADULT_DURATION) <
|
if member.birthdate_date:
|
||||||
fields.Datetime.from_string(self.birthdate_date))
|
member.is_minor = ((datetime.now() - self.ADULT_DURATION) <
|
||||||
else:
|
fields.Datetime.from_string(member.birthdate_date))
|
||||||
self.is_minor = False
|
else:
|
||||||
|
member.is_minor = False
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" GOLEM Member Minor tests """
|
||||||
|
|
||||||
from odoo.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
class GolemMemberMinorTestCase(TransactionCase):
|
class GolemMemberMinorTestCase(TransactionCase):
|
||||||
|
""" GOLEM Member Minor tests """
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(GolemMemberMinorTestCase, self).setUp()
|
super(GolemMemberMinorTestCase, self).setUp()
|
||||||
@ -28,10 +30,10 @@ class GolemMemberMinorTestCase(TransactionCase):
|
|||||||
|
|
||||||
def test_member_minor(self):
|
def test_member_minor(self):
|
||||||
""" Test minor computing """
|
""" Test minor computing """
|
||||||
m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Joe'})
|
new_m = self.member_model.create({'lastname': u'Doe', 'firstname': u'Joe'})
|
||||||
self.assertFalse(m.is_minor)
|
self.assertFalse(new_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'Bob',
|
||||||
'birthdate_date': '1990-01-01'})
|
'birthdate_date': '1990-01-01'})
|
||||||
self.assertFalse(m.is_minor)
|
self.assertFalse(new_m.is_minor)
|
||||||
m.write({'birthdate_date': '2015-01-01'})
|
new_m.write({'birthdate_date': '2015-01-01'})
|
||||||
self.assertTrue(m.is_minor)
|
self.assertTrue(new_m.is_minor)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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
|
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
|
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>
|
<data>
|
||||||
|
|
||||||
<!-- Form -->
|
<!-- 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="name">Add Minor Page/Tab</field>
|
||||||
<field name="model">golem.member</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="arch" type="xml">
|
||||||
<field name="pictures_agreement" position="replace" />
|
<field name="pictures_agreement" position="replace" />
|
||||||
</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<page name="contact_details" position="after">
|
<page name="contact_details" position="after">
|
||||||
<page name="minor_page" string="Minor"
|
<page name="minor_page" string="Minor"
|
||||||
attrs="{'invisible': [('is_minor', '=', False)]}">
|
attrs="{'invisible': [('is_minor', '=', False)]}">
|
||||||
@ -52,17 +50,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- Search -->
|
<!-- 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="name">Add Minor/Adult filters</field>
|
||||||
<field name="model">golem.member</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">
|
<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"
|
<filter name="filter_is_minor" string="Is minor"
|
||||||
domain="[('is_minor', '=', True)]"/>
|
domain="[('is_minor', '=', True)]"/>
|
||||||
<filter name="filter_is_adult" string="Is adult"
|
<filter name="filter_is_adult" string="Is adult"
|
||||||
domain="[('is_minor', '!=', True)]"/>
|
domain="[('is_minor', '!=', True)]"/>
|
||||||
</group>
|
</filter>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user