[ADD]GOLEM Activity Session places modules for management of minimum, overbook...
This commit is contained in:
parent
e23b1bf7ba
commit
ffe75f0430
18
golem_activity_session_place/__init__.py
Normal file
18
golem_activity_session_place/__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_activity_session_place/__openerp__.py
Normal file
32
golem_activity_session_place/__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 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']
|
||||
}
|
39
golem_activity_session_place/i18n/fr.po
Normal file
39
golem_activity_session_place/i18n/fr.po
Normal file
@ -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"
|
||||
|
@ -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 ""
|
||||
|
18
golem_activity_session_place/models/__init__.py
Normal file
18
golem_activity_session_place/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_activity_session
|
@ -0,0 +1,56 @@
|
||||
# -*- 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 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)
|
65
golem_activity_session_place/views/golem_activity_view.xml
Normal file
65
golem_activity_session_place/views/golem_activity_view.xml
Normal file
@ -0,0 +1,65 @@
|
||||
<?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>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="view_form" model="ir.ui.view">
|
||||
<field name="name">GOLEM Activity Sessions Places Form additions</field>
|
||||
<field name="model">golem.activity.session</field>
|
||||
<field name="inherit_id" ref="golem_activity_session.view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="places" position="after">
|
||||
<field name="places_min" />
|
||||
<field name="is_overbooked" />
|
||||
<field name="places_overbooked"
|
||||
attrs="{'invisible': [('is_overbooked', '=', False)]}" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="session_tree" model="ir.ui.view">
|
||||
<field name="name">Session list places adaptations</field>
|
||||
<field name="model">golem.activity.session</field>
|
||||
<field name="inherit_id" ref="golem_activity_session.session_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<tree position="attributes">
|
||||
<attribute name="colors">darkgrey: places_used < places_min; red: places_remain == 0; orange: places_remain <= 4;</attribute>
|
||||
</tree>
|
||||
<field name="places_remain" position="after">
|
||||
<field name="places_used" invisible="True" />
|
||||
<field name="places_min" invisible="True" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Searches -->
|
||||
<record id="searches" model="ir.ui.view">
|
||||
<field name="name">GOLEM Activity Sessions Searches</field>
|
||||
<field name="model">golem.activity.session</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<filter name="full_session" string="Full"
|
||||
domain="[('places_remain', '=', 0)]" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue
Block a user