[IMP]GOLEM Activity Session simplification : no management of min or overbook session per default

This commit is contained in:
Fabien Bourgeois 2016-08-03 17:24:40 +02:00
parent 4f9ecf0088
commit e23b1bf7ba
4 changed files with 13 additions and 49 deletions

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-03 14:49+0000\n" "POT-Creation-Date: 2016-08-03 15:20+0000\n"
"PO-Revision-Date: 2016-08-03 14:49+0000\n" "PO-Revision-Date: 2016-08-03 15:20+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -473,17 +473,11 @@ msgid "Net Weight"
msgstr "Net Weight" msgstr "Net Weight"
#. module: golem_activity_session #. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:229 #: code:addons/golem_activity_session/models/golem_activity_session.py:215
#, python-format #, python-format
msgid "Number of places cannot be negative." msgid "Number of places cannot be negative."
msgstr "Le nombre de places ne peut pas être négatif" msgstr "Le nombre de places ne peut pas être négatif"
#. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:232
#, python-format
msgid "Overbooked places cannot be inferior than places"
msgstr "Le nombre de places avec surcharge ne peut être inférieur aux places"
#. module: golem_activity_session #. module: golem_activity_session
#: field:golem.activity.session,places:0 #: field:golem.activity.session,places:0
msgid "Places" msgid "Places"
@ -623,7 +617,7 @@ msgid "Small-sized image of the product. It is automatically resized as a 64x64p
msgstr "Small-sized image of the product. It is automatically resized as a 64x64px image, with aspect ratio preserved. Use this field anywhere a small image is required." msgstr "Small-sized image of the product. It is automatically resized as a 64x64px image, with aspect ratio preserved. Use this field anywhere a small image is required."
#. module: golem_activity_session #. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:212 #: code:addons/golem_activity_session/models/golem_activity_session.py:205
#, python-format #, python-format
msgid "Sorry, there is no more place !" msgid "Sorry, there is no more place !"
msgstr "Désolé mais il n'y a plus de place disponible !" msgstr "Désolé mais il n'y a plus de place disponible !"

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-08-03 14:49+0000\n" "POT-Creation-Date: 2016-08-03 15:20+0000\n"
"PO-Revision-Date: 2016-08-03 14:49+0000\n" "PO-Revision-Date: 2016-08-03 15:20+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -470,17 +470,11 @@ msgid "Net Weight"
msgstr "" msgstr ""
#. module: golem_activity_session #. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:229 #: code:addons/golem_activity_session/models/golem_activity_session.py:215
#, python-format #, python-format
msgid "Number of places cannot be negative." msgid "Number of places cannot be negative."
msgstr "" msgstr ""
#. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:232
#, python-format
msgid "Overbooked places cannot be inferior than places"
msgstr ""
#. module: golem_activity_session #. module: golem_activity_session
#: field:golem.activity.session,places:0 #: field:golem.activity.session,places:0
msgid "Places" msgid "Places"
@ -620,7 +614,7 @@ msgid "Small-sized image of the product. It is automatically resized as a 64x64p
msgstr "" msgstr ""
#. module: golem_activity_session #. module: golem_activity_session
#: code:addons/golem_activity_session/models/golem_activity_session.py:212 #: code:addons/golem_activity_session/models/golem_activity_session.py:205
#, python-format #, python-format
msgid "Sorry, there is no more place !" msgid "Sorry, there is no more place !"
msgstr "" msgstr ""

View File

@ -188,21 +188,14 @@ class GolemActivitySession(models.Model):
'after end of the period.')) 'after end of the period.'))
places = fields.Integer('Places', default=0) places = fields.Integer('Places', default=0)
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)
places_remain = fields.Integer('Remaining places', store=True, places_remain = fields.Integer('Remaining places', store=True,
compute='_compute_places_remain') compute='_compute_places_remain')
@api.depends('places', 'is_overbooked', 'places_overbooked', 'member_ids') @api.depends('places', 'member_ids')
def _compute_places_remain(self): def _compute_places_remain(self):
for s in self: for s in self:
used = len(s.member_ids) used = len(s.member_ids)
if not s.is_overbooked:
s.places_remain = s.places - used s.places_remain = s.places - used
else:
s.places_remain = s.places_overbooked - used
@api.constrains('places_remain') @api.constrains('places_remain')
def _check_remaining_places(self): def _check_remaining_places(self):
@ -212,22 +205,12 @@ class GolemActivitySession(models.Model):
emsg = _('Sorry, there is no more place !') emsg = _('Sorry, there is no more place !')
raise models.ValidationError(emsg) raise models.ValidationError(emsg)
@api.onchange('is_overbooked', 'places') @api.constrains('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): def _check_places(self):
""" Check integers are signed and overbooked to be superior than """ Check integers are signed and overbooked to be superior than
normal places """ normal places """
for v in self: for v in self:
for f in ['places', 'places_overbooked']: for f in ['places']:
if v[f] < 0: if v[f] < 0:
emsg = _('Number of places cannot be negative.') emsg = _('Number of places cannot be negative.')
raise models.ValidationError(emsg) 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)

View File

@ -50,10 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="animator_id" /> <field name="animator_id" />
<field name="type_of" /> <field name="type_of" />
<field name="places" /> <field name="places" />
<field name="places_min" />
<field name="is_overbooked" />
<field name="places_overbooked"
attrs="{'invisible': [('is_overbooked', '=', False)]}" />
</group> </group>
<group> <group>
<field name="is_recurrent" /> <field name="is_recurrent" />
@ -107,8 +103,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="name">Session list</field> <field name="name">Session list</field>
<field name="model">golem.activity.session</field> <field name="model">golem.activity.session</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree colors="darkgrey: places_used &lt; places_min; <tree colors="red: places_remain == 0;
red: places_remain == 0;
orange: places_remain &lt;= 4;"> orange: places_remain &lt;= 4;">
<field name="is_recurrent" invisible="True" /> <field name="is_recurrent" invisible="True" />
<field name="season_id" /> <field name="season_id" />
@ -120,8 +115,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
attrs="{'invisible': [('is_recurrent', '=', True)]}" /> attrs="{'invisible': [('is_recurrent', '=', True)]}" />
<field name="places" invisible="True" /> <field name="places" invisible="True" />
<field name="places_remain" string="Remain" /> <field name="places_remain" string="Remain" />
<field name="places_used" invisible="True" />
<field name="places_min" invisible="True" />
<field name="list_price" sum="True" /> <field name="list_price" sum="True" />
</tree> </tree>
</field> </field>