[IMP]GOLEM Season : inverse link with membership products (many products for 1 season)
This commit is contained in:
parent
209013864e
commit
0e7e33bada
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2016-2018 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
|
||||
@ -18,12 +18,18 @@
|
||||
{
|
||||
'name': 'GOLEM seasons',
|
||||
'summary': 'GOLEM non-profit seasons management',
|
||||
'version': '10.0.1.0.1',
|
||||
'description': '''GOLEM non-profit seasons management :
|
||||
- add season with name and period ;
|
||||
- choose on per default season ;
|
||||
- link optionnally one or many memberships types''',
|
||||
'version': '10.0.1.1.0',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['golem_base'],
|
||||
'data': ['security/ir.model.access.csv', 'views/golem_season_views.xml']
|
||||
'data': ['security/ir.model.access.csv',
|
||||
'views/golem_season_views.xml',
|
||||
'views/membership_views.xml']
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-01-18 14:18+0000\n"
|
||||
"PO-Revision-Date: 2018-01-18 14:18+0000\n"
|
||||
"POT-Creation-Date: 2018-02-28 07:38+0000\n"
|
||||
"PO-Revision-Date: 2018-02-28 07:38+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -31,7 +31,7 @@ msgid "Created on"
|
||||
msgstr "Créé le"
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:75
|
||||
#: code:addons/golem_season/models/golem_season.py:73
|
||||
#, python-format
|
||||
msgid "Current period cannot be included into another existing period."
|
||||
msgstr "La période actuelle est en conflit avec une période existante."
|
||||
@ -57,7 +57,7 @@ msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:71
|
||||
#: code:addons/golem_season/models/golem_season.py:69
|
||||
#, python-format
|
||||
msgid "End of the period is in range of an existing period."
|
||||
msgstr "La fin de la période est en conflit avec une période existante."
|
||||
@ -93,15 +93,21 @@ msgstr "Dernière mise à jour par"
|
||||
msgid "Last Updated on"
|
||||
msgstr "Dernière mise à jour le"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model.fields,field_description:golem_season.field_product_product_season_id
|
||||
#: model:ir.model.fields,field_description:golem_season.field_product_template_season_id
|
||||
msgid "Linked season"
|
||||
msgstr "Saison liée"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.ui.view,arch_db:golem_season.golem_season_view_form
|
||||
msgid "Make this season as default"
|
||||
msgstr "Activer cette saison par défaut"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model.fields,field_description:golem_season.field_golem_season_membership_id
|
||||
msgid "Membership type"
|
||||
msgstr "Type d'adhésion"
|
||||
#: model:ir.model.fields,field_description:golem_season.field_golem_season_membership_ids
|
||||
msgid "Membership types"
|
||||
msgstr "Types d'adhésion"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model.fields,field_description:golem_season.field_golem_season_date_end
|
||||
@ -113,8 +119,14 @@ msgstr "Fin de la période"
|
||||
msgid "Period start"
|
||||
msgstr "Début de la période"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model,name:golem_season.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr "Modèle d'article"
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.ui.view,arch_db:golem_season.golem_season_view_form
|
||||
#: model:ir.ui.view,arch_db:golem_season.membership_product_search_form_view_inherit_golem_season
|
||||
msgid "Season"
|
||||
msgstr "Saison"
|
||||
|
||||
@ -129,25 +141,25 @@ msgid "Seasons"
|
||||
msgstr "Saisons"
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:62
|
||||
#: code:addons/golem_season/models/golem_season.py:60
|
||||
#, python-format
|
||||
msgid "Start of the period cannot be after end of the period."
|
||||
msgstr "Le début de la période ne peut être postérieur à sa fin."
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:67
|
||||
#: code:addons/golem_season/models/golem_season.py:65
|
||||
#, python-format
|
||||
msgid "Start of the period is in range of an existing period."
|
||||
msgstr "Le début de la période est en conflit avec une période existante."
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:58
|
||||
#: code:addons/golem_season/models/golem_season.py:56
|
||||
#, python-format
|
||||
msgid "The date end is required"
|
||||
msgstr "The date end is required"
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:60
|
||||
#: code:addons/golem_season/models/golem_season.py:58
|
||||
#, python-format
|
||||
msgid "The date start is required"
|
||||
msgstr "The date start is required"
|
||||
@ -160,8 +172,7 @@ msgid "This season name has already been used."
|
||||
msgstr "Ce nom pour la saison a déjà été utilisé. Merci d'en choisir un autre."
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:114
|
||||
#: code:addons/golem_season/models/golem_season.py:112
|
||||
#, python-format
|
||||
msgid "You can't delete the default season"
|
||||
msgstr "Vous ne pouvez pas supprimer la saison par défaut"
|
||||
|
||||
|
@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-01-18 14:18+0000\n"
|
||||
"PO-Revision-Date: 2018-01-18 14:18+0000\n"
|
||||
"POT-Creation-Date: 2018-02-28 07:38+0000\n"
|
||||
"PO-Revision-Date: 2018-02-28 07:38+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -31,7 +31,7 @@ msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:75
|
||||
#: code:addons/golem_season/models/golem_season.py:73
|
||||
#, python-format
|
||||
msgid "Current period cannot be included into another existing period."
|
||||
msgstr ""
|
||||
@ -57,7 +57,7 @@ msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:71
|
||||
#: code:addons/golem_season/models/golem_season.py:69
|
||||
#, python-format
|
||||
msgid "End of the period is in range of an existing period."
|
||||
msgstr ""
|
||||
@ -93,14 +93,20 @@ msgstr ""
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model.fields,field_description:golem_season.field_product_product_season_id
|
||||
#: model:ir.model.fields,field_description:golem_season.field_product_template_season_id
|
||||
msgid "Linked season"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.ui.view,arch_db:golem_season.golem_season_view_form
|
||||
msgid "Make this season as default"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model.fields,field_description:golem_season.field_golem_season_membership_id
|
||||
msgid "Membership type"
|
||||
#: model:ir.model.fields,field_description:golem_season.field_golem_season_membership_ids
|
||||
msgid "Membership types"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
@ -113,8 +119,14 @@ msgstr ""
|
||||
msgid "Period start"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.model,name:golem_season.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: model:ir.ui.view,arch_db:golem_season.golem_season_view_form
|
||||
#: model:ir.ui.view,arch_db:golem_season.membership_product_search_form_view_inherit_golem_season
|
||||
msgid "Season"
|
||||
msgstr ""
|
||||
|
||||
@ -129,25 +141,25 @@ msgid "Seasons"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:62
|
||||
#: code:addons/golem_season/models/golem_season.py:60
|
||||
#, python-format
|
||||
msgid "Start of the period cannot be after end of the period."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:67
|
||||
#: code:addons/golem_season/models/golem_season.py:65
|
||||
#, python-format
|
||||
msgid "Start of the period is in range of an existing period."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:58
|
||||
#: code:addons/golem_season/models/golem_season.py:56
|
||||
#, python-format
|
||||
msgid "The date end is required"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:60
|
||||
#: code:addons/golem_season/models/golem_season.py:58
|
||||
#, python-format
|
||||
msgid "The date start is required"
|
||||
msgstr ""
|
||||
@ -160,7 +172,7 @@ msgid "This season name has already been used."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_season
|
||||
#: code:addons/golem_season/models/golem_season.py:114
|
||||
#: code:addons/golem_season/models/golem_season.py:112
|
||||
#, python-format
|
||||
msgid "You can't delete the default season"
|
||||
msgstr ""
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2016-2018 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_season
|
||||
from . import product_template, golem_season
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2016-2018 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
|
||||
@ -28,21 +28,22 @@ class GolemSeason(models.Model):
|
||||
_('This season name has already been used.'))]
|
||||
|
||||
name = fields.Char('Season name', copy=False, required=True)
|
||||
membership_id = fields.Many2one('product.template', 'Membership type',
|
||||
domain=[('membership', '=', True)])
|
||||
membership_ids = fields.One2many('product.template', 'season_id',
|
||||
string='Membership types',
|
||||
domain=[('membership', '=', True)])
|
||||
member_counter = fields.Integer('Counter for member number generation',
|
||||
readonly=True, default=1)
|
||||
date_start = fields.Date('Period start')
|
||||
date_end = fields.Date('Period end')
|
||||
|
||||
@api.onchange('membership_id')
|
||||
@api.onchange('membership_ids')
|
||||
def _onchange_season_dates(self):
|
||||
""" Sets defaults dates according to membership type """
|
||||
for season in self:
|
||||
if season.membership_id and not season.date_start:
|
||||
if season.membership_ids and not season.date_start:
|
||||
season.update({
|
||||
'date_start': season.membership_id.membership_date_from,
|
||||
'date_end': season.membership_id.membership_date_to
|
||||
'date_start': season.membership_ids[0].membership_date_from,
|
||||
'date_end': season.membership_ids[0].membership_date_to
|
||||
})
|
||||
|
||||
@api.constrains('date_start', 'date_end')
|
||||
|
37
golem_season/models/product_template.py
Normal file
37
golem_season/models/product_template.py
Normal file
@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 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/>.
|
||||
|
||||
""" Product adaptations """
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
""" Product Template adaptations """
|
||||
_inherit = 'product.template'
|
||||
|
||||
season_id = fields.Many2one('golem.season', 'Linked season', index=True)
|
||||
|
||||
@api.onchange('season_id')
|
||||
def onchange_season(self):
|
||||
""" Adapts period to selected season if needed """
|
||||
for product in self:
|
||||
if product.membership and product.season_id \
|
||||
and not product.membership_date_from:
|
||||
product.update({
|
||||
'membership_date_from': product.season_id.date_start,
|
||||
'membership_date_to': product.season_id.date_end
|
||||
})
|
@ -74,5 +74,5 @@ class TestGolemSeason(TransactionCase):
|
||||
'membership_date_to': '2018-11-01'})
|
||||
|
||||
new_season = self.env['golem.season'].create({'name': 'Name',
|
||||
'membership_id': membership.id})
|
||||
self.assertEqual(new_season.membership_id, membership)
|
||||
'membership_ids': [(4, membership.id, 0)]})
|
||||
self.assertEqual(new_season.membership_ids[0], membership)
|
||||
|
@ -36,7 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<group string="Season">
|
||||
<field name="is_default" invisible="True" />
|
||||
<field name="name" attrs="{'required': True}" />
|
||||
<field name="membership_id" options="{'no_create': true}"/>
|
||||
<field name="membership_ids" widget="many2many_tags"
|
||||
options="{'no_create': True}" />
|
||||
<field name="date_start"
|
||||
attrs="{'required': [('date_end', '!=', False)]}" />
|
||||
<field name="date_end"
|
||||
|
54
golem_season/views/membership_views.xml
Normal file
54
golem_season/views/membership_views.xml
Normal file
@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright 2018 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/>.
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- Forms -->
|
||||
<record id="membership_products_view_form_inherit_golem_season"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Membership Product Form adaptations</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="membership.membership_products_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="default_code" position="before">
|
||||
<field name="season_id" options="{'no_create': True}" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Searches -->
|
||||
<record id="membership_product_search_form_view_inherit_golem_season"
|
||||
model="ir.ui.view">
|
||||
<field name="name">Membership Product Search adaptations</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="membership.membership_product_search_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="name" position="after">
|
||||
<field name="season_id" />
|
||||
</field>
|
||||
<xpath expr="//group/filter[1]" position="after">
|
||||
<filter name="group_season" string="Season"
|
||||
context="{'group_by': 'season_id'}" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
Loading…
x
Reference in New Issue
Block a user