From ffe75f04305aa8e848a278cb46c89577225e6ef9 Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Wed, 3 Aug 2016 17:25:18 +0200 Subject: [PATCH] [ADD]GOLEM Activity Session places modules for management of minimum, overbook... --- golem_activity_session_place/__init__.py | 18 +++++ golem_activity_session_place/__openerp__.py | 32 +++++++++ golem_activity_session_place/i18n/fr.po | 39 +++++++++++ .../i18n/golem_activity_session_place.pot | 39 +++++++++++ .../models/__init__.py | 18 +++++ .../models/golem_activity_session.py | 56 ++++++++++++++++ .../views/golem_activity_view.xml | 65 +++++++++++++++++++ 7 files changed, 267 insertions(+) create mode 100644 golem_activity_session_place/__init__.py create mode 100644 golem_activity_session_place/__openerp__.py create mode 100644 golem_activity_session_place/i18n/fr.po create mode 100644 golem_activity_session_place/i18n/golem_activity_session_place.pot create mode 100644 golem_activity_session_place/models/__init__.py create mode 100644 golem_activity_session_place/models/golem_activity_session.py create mode 100644 golem_activity_session_place/views/golem_activity_view.xml diff --git a/golem_activity_session_place/__init__.py b/golem_activity_session_place/__init__.py new file mode 100644 index 0000000..2fca3d2 --- /dev/null +++ b/golem_activity_session_place/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 Fabien Bourgeois +# +# 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 . + +from . import models diff --git a/golem_activity_session_place/__openerp__.py b/golem_activity_session_place/__openerp__.py new file mode 100644 index 0000000..a954a64 --- /dev/null +++ b/golem_activity_session_place/__openerp__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 Fabien Bourgeois +# +# 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 . + +{ + 'name': 'GOLEM Activity Sessions Places', + 'summary': 'GOLEM Activities Session avdanced places management', + 'description': ''' Management of minimum places, overbook and max + overbook... ''', + 'version': '0.1', + 'category': 'GOLEM', + 'author': 'Fabien Bourgeois', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'auto_install': False, + 'depends': ['golem_activity_session'], + 'data': ['views/golem_activity_view.xml'] +} diff --git a/golem_activity_session_place/i18n/fr.po b/golem_activity_session_place/i18n/fr.po new file mode 100644 index 0000000..8ea24c2 --- /dev/null +++ b/golem_activity_session_place/i18n/fr.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_activity_session_place +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-03 15:21+0000\n" +"PO-Revision-Date: 2016-08-03 15:21+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: golem_activity_session_place +#: view:golem.activity.session:golem_activity_session_place.searches +msgid "Full" +msgstr "Plein" + +#. module: golem_activity_session_place +#: model:ir.model,name:golem_activity_session_place.model_golem_activity_session +msgid "GOLEM Activities Sessions" +msgstr "Séances des activités" + +#. module: golem_activity_session_place +#: code:addons/golem_activity_session_place/models/golem_activity_session.py:52 +#, python-format +msgid "Number of places cannot be negative." +msgstr "Le nombre de places ne peut pas être négatif" + +#. module: golem_activity_session_place +#: code:addons/golem_activity_session_place/models/golem_activity_session.py:55 +#, python-format +msgid "Overbooked places cannot be inferior than places" +msgstr "Le nombre de places avec surcharge ne peut être inférieur aux places" + diff --git a/golem_activity_session_place/i18n/golem_activity_session_place.pot b/golem_activity_session_place/i18n/golem_activity_session_place.pot new file mode 100644 index 0000000..022724d --- /dev/null +++ b/golem_activity_session_place/i18n/golem_activity_session_place.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * golem_activity_session_place +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-08-03 15:20+0000\n" +"PO-Revision-Date: 2016-08-03 15:20+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: golem_activity_session_place +#: view:golem.activity.session:golem_activity_session_place.searches +msgid "Full" +msgstr "" + +#. module: golem_activity_session_place +#: model:ir.model,name:golem_activity_session_place.model_golem_activity_session +msgid "GOLEM Activities Sessions" +msgstr "" + +#. module: golem_activity_session_place +#: code:addons/golem_activity_session_place/models/golem_activity_session.py:52 +#, python-format +msgid "Number of places cannot be negative." +msgstr "" + +#. module: golem_activity_session_place +#: code:addons/golem_activity_session_place/models/golem_activity_session.py:55 +#, python-format +msgid "Overbooked places cannot be inferior than places" +msgstr "" + diff --git a/golem_activity_session_place/models/__init__.py b/golem_activity_session_place/models/__init__.py new file mode 100644 index 0000000..1bba04c --- /dev/null +++ b/golem_activity_session_place/models/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2016 Fabien Bourgeois +# +# 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 . + +from . import golem_activity_session diff --git a/golem_activity_session_place/models/golem_activity_session.py b/golem_activity_session_place/models/golem_activity_session.py new file mode 100644 index 0000000..e54d488 --- /dev/null +++ b/golem_activity_session_place/models/golem_activity_session.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +# copyright 2016 fabien bourgeois +# +# 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 . + +from openerp import models, fields, api, _ + + +class GolemActivitySession(models.Model): + _inherit = 'golem.activity.session' + + places_min = fields.Integer('Minimum places', default=0, + help='Minimum places to maintain the session') + is_overbooked = fields.Boolean('Allow overbook?', default=False) + places_overbooked = fields.Integer('Places with overbook', default=0) + + @api.depends('places', 'is_overbooked', 'places_overbooked', 'member_ids') + def _compute_places_remain(self): + for s in self: + used = len(s.member_ids) + if not s.is_overbooked: + s.places_remain = s.places - used + else: + s.places_remain = s.places_overbooked - used + + @api.onchange('is_overbooked', 'places') + def onchange_is_overbooked(self): + for s in self: + if s.places and s.is_overbooked: + if not s.places_overbooked or (s.places_overbooked < s.places): + s.places_overbooked = s.places + 1 + + @api.constrains('places', 'places_overbooked') + def _check_places(self): + """ Check integers are signed and overbooked to be superior than + normal places """ + for v in self: + for f in ['places', 'places_overbooked']: + if v[f] < 0: + emsg = _('Number of places cannot be negative.') + raise models.ValidationError(emsg) + if v.is_overbooked and (v.places_overbooked <= v.places): + emsg = _('Overbooked places cannot be inferior than places') + raise models.ValidationError(emsg) diff --git a/golem_activity_session_place/views/golem_activity_view.xml b/golem_activity_session_place/views/golem_activity_view.xml new file mode 100644 index 0000000..92fa3cc --- /dev/null +++ b/golem_activity_session_place/views/golem_activity_view.xml @@ -0,0 +1,65 @@ + + + + + + + + GOLEM Activity Sessions Places Form additions + golem.activity.session + + + + + + + + + + + + + Session list places adaptations + golem.activity.session + + + + darkgrey: places_used < places_min; red: places_remain == 0; orange: places_remain <= 4; + + + + + + + + + + + GOLEM Activity Sessions Searches + golem.activity.session + + + + + + + + +