[ADD]GOLEM seasons
This commit is contained in:
parent
c50c594e69
commit
b98cd7a022
18
golem_season/__init__.py
Normal file
18
golem_season/__init__.py
Normal 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 models
|
32
golem_season/__openerp__.py
Normal file
32
golem_season/__openerp__.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- 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 seasons',
|
||||
'summary': 'GOLEM non-profit seasons management',
|
||||
'description': '''
|
||||
Non-profit french MJC seasons management with dates ranges
|
||||
''',
|
||||
'version': '0.1',
|
||||
'category': 'Non-profit management',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': True,
|
||||
'depends': ['membership'],
|
||||
'data': ['views/golem_season_view.xml']
|
||||
}
|
18
golem_season/models/__init__.py
Normal file
18
golem_season/models/__init__.py
Normal 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_season
|
54
golem_season/models/golem_season.py
Normal file
54
golem_season/models/golem_season.py
Normal file
@ -0,0 +1,54 @@
|
||||
# -*- 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 openerp import models, fields, api, _
|
||||
|
||||
|
||||
class GolemSeason(models.Model):
|
||||
""" GOLEM Season """
|
||||
_name = 'golem.season'
|
||||
_description = 'GOLEM Season'
|
||||
_order = 'date_start desc'
|
||||
|
||||
name = fields.Char('Season name')
|
||||
date_start = fields.Date('Period start')
|
||||
date_end = fields.Date('Period end')
|
||||
|
||||
@api.constrains('date_start', 'date_end')
|
||||
def _check_period(self):
|
||||
""" Check if end date if after start date and if there is no conflict
|
||||
with existing periods """
|
||||
for season in self:
|
||||
if season.date_start > season.date_end:
|
||||
raise models.ValidationError(_('Start of the period cannot be '
|
||||
'after end of the period.'))
|
||||
else:
|
||||
seasons = self.env['golem.season'].search([])
|
||||
for s in seasons:
|
||||
print s.name
|
||||
if s.date_start < season.date_start < s.date_end:
|
||||
msg = _('Start of the period is in range of an '
|
||||
'existing period {}'.format(s.name))
|
||||
raise models.ValidationError(msg)
|
||||
if s.date_start < season.date_end < s.date_end:
|
||||
msg = _('End of the period is in range of an '
|
||||
'existing period {}'.format(s.name))
|
||||
raise models.ValidationError(msg)
|
||||
if season.date_start < s.date_start < season.date_end:
|
||||
msg = _('Period {} cannot be included into current '
|
||||
'period'.format(s.name))
|
||||
raise models.ValidationError(msg)
|
73
golem_season/views/golem_season_view.xml
Normal file
73
golem_season/views/golem_season_view.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?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>
|
||||
|
||||
<!-- Forms -->
|
||||
<record id="form" model="ir.ui.view">
|
||||
<field name="name">GOLEM Season Form</field>
|
||||
<field name="model">golem.season</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<group string="Season">
|
||||
<field name="name" />
|
||||
<field name="date_start" />
|
||||
<field name="date_end" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Trees -->
|
||||
<record id="tree" model="ir.ui.view">
|
||||
<field name="name">GOLEM Seasons</field>
|
||||
<field name="model">golem.season</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree>
|
||||
<field name="name" />
|
||||
<field name="date_start" />
|
||||
<field name="date_end" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Search -->
|
||||
<record id="filter" model="ir.ui.view">
|
||||
<field name="name">GOLEM Seasons Filters</field>
|
||||
<field name="model">golem.season</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Actions -->
|
||||
<act_window id="action_list" name="GOLEM Seasons"
|
||||
res_model="golem.season" view_mode="tree,form" />
|
||||
<!-- Menus -->
|
||||
<menuitem id="menu_seasons" name="GOLEM Seasons"
|
||||
parent="base.menu_marketing_config_association" sequence="2"
|
||||
action="action_list" />
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue
Block a user