[MIG][IMP]GOLEM activity registration place migration to v10, and better guidelines
This commit is contained in:
parent
a955633375
commit
4a9cec73c9
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017 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
|
||||
@ -23,8 +23,8 @@
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
'application': False,
|
||||
'installable': False,
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'depends': ['golem_activity_registration'],
|
||||
'data': ['views/golem_activity_view.xml']
|
||||
'data': ['views/golem_activity_views.xml']
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-10-10 16:26+0000\n"
|
||||
"PO-Revision-Date: 2016-10-10 16:26+0000\n"
|
||||
"POT-Creation-Date: 2017-05-01 22:35+0000\n"
|
||||
"PO-Revision-Date: 2017-05-01 22:35+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -16,7 +16,7 @@ msgstr ""
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,is_overbooked:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_is_overbooked
|
||||
msgid "Allow overbook?"
|
||||
msgstr "Autoriser la surcharge ?"
|
||||
|
||||
@ -26,34 +26,28 @@ msgid "GOLEM Activity"
|
||||
msgstr "Activité"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,places_min:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_places_min
|
||||
msgid "Minimum places"
|
||||
msgstr "Places minimum"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: help:golem.activity,places_min:0
|
||||
#: model:ir.model.fields,help:golem_activity_place.field_golem_activity_places_min
|
||||
msgid "Minimum places to maintain the activity"
|
||||
msgstr "Nombre de places minimales pour maintenir l'activité"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:51
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:57
|
||||
#, python-format
|
||||
msgid "Number of places cannot be negative."
|
||||
msgstr "Le nombre de places ne peut pas être négatif"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:54
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:61
|
||||
#, python-format
|
||||
msgid "Overbooked places cannot be inferior than places"
|
||||
msgstr "Le nombre de places avec surcharge ne peut être inférieur aux place
|
||||
msgstr "Le nombre de places avec surcharge ne peut être inférieur aux places"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,places_overbooked:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_places_overbooked
|
||||
msgid "Places with overbook"
|
||||
msgstr "Places avec surcharge"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: view:golem.activity:golem_activity_place.tree
|
||||
msgid "darkgrey: places_used < places_min; red: places_remain == 0; orange: places_remain <= 4;"
|
||||
msgstr "darkgrey: places_used < places_min; red: places_remain == 0; orange: places_remain <= 4;"
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-10-10 16:25+0000\n"
|
||||
"PO-Revision-Date: 2016-10-10 16:25+0000\n"
|
||||
"POT-Creation-Date: 2017-05-01 22:34+0000\n"
|
||||
"PO-Revision-Date: 2017-05-01 22:34+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
@ -16,7 +16,7 @@ msgstr ""
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,is_overbooked:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_is_overbooked
|
||||
msgid "Allow overbook?"
|
||||
msgstr ""
|
||||
|
||||
@ -26,34 +26,29 @@ msgid "GOLEM Activity"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,places_min:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_places_min
|
||||
msgid "Minimum places"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: help:golem.activity,places_min:0
|
||||
#: model:ir.model.fields,help:golem_activity_place.field_golem_activity_places_min
|
||||
msgid "Minimum places to maintain the activity"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:51
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:57
|
||||
#, python-format
|
||||
msgid "Number of places cannot be negative."
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:54
|
||||
#: code:addons/golem_activity_place/models/golem_activity.py:61
|
||||
#, python-format
|
||||
msgid "Overbooked places cannot be inferior than places"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: field:golem.activity,places_overbooked:0
|
||||
#: model:ir.model.fields,field_description:golem_activity_place.field_golem_activity_places_overbooked
|
||||
msgid "Places with overbook"
|
||||
msgstr ""
|
||||
|
||||
#. module: golem_activity_place
|
||||
#: view:golem.activity:golem_activity_place.tree
|
||||
msgid "darkgrey: places_used < places_min; red: places_remain == 0; orange: places_remain <= 4;"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# copyright 2016 fabien bourgeois <fabien@yaltik.com>
|
||||
# copyright 2017 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,10 +15,12 @@
|
||||
# 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/>.
|
||||
|
||||
""" GOLEM Activity Advanced Places management """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class GolemActivity(models.Model):
|
||||
""" GOLEM Activity Advanced Places management """
|
||||
_inherit = 'golem.activity'
|
||||
|
||||
places_min = fields.Integer('Minimum places', default=0,
|
||||
@ -26,30 +28,35 @@ class GolemActivity(models.Model):
|
||||
is_overbooked = fields.Boolean('Allow overbook?', default=False)
|
||||
places_overbooked = fields.Integer('Places with overbook', default=0)
|
||||
|
||||
@api.one
|
||||
@api.multi
|
||||
@api.depends('places', 'is_overbooked', 'places_overbooked', 'places_used')
|
||||
def _compute_places_remain(self):
|
||||
if not self.is_overbooked:
|
||||
self.places_remain = self.places - self.places_used
|
||||
else:
|
||||
self.places_remain = self.places_overbooked - self.places_used
|
||||
""" Overwrite : computes remaining places """
|
||||
for activity in self:
|
||||
if not activity.is_overbooked:
|
||||
activity.places_remain = activity.places - activity.places_used
|
||||
else:
|
||||
activity.places_remain = activity.places_overbooked - activity.places_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
|
||||
""" Realtime display for places and overbooked """
|
||||
for activity in self:
|
||||
if activity.places and activity.is_overbooked:
|
||||
if not activity.places_overbooked or \
|
||||
(activity.places_overbooked < activity.places):
|
||||
activity.places_overbooked = activity.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:
|
||||
for activity in self:
|
||||
for field in ['places', 'places_overbooked']:
|
||||
if activity[field] < 0:
|
||||
emsg = _('Number of places cannot be negative.')
|
||||
raise models.ValidationError(emsg)
|
||||
if v.is_overbooked and (v.places_overbooked <= v.places):
|
||||
if activity.is_overbooked and \
|
||||
(activity.places_overbooked <= activity.places):
|
||||
emsg = _('Overbooked places cannot be inferior than places')
|
||||
raise models.ValidationError(emsg)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
# Copyright 2017 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,11 +15,14 @@
|
||||
# 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/>.
|
||||
|
||||
""" GOLEM Activity Places Tests """
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.models import ValidationError
|
||||
|
||||
|
||||
class GolemActivitySessionTestCase(TransactionCase):
|
||||
""" GOLEM Activity Places Tests """
|
||||
|
||||
def setUp(self):
|
||||
super(GolemActivitySessionTestCase, self).setUp()
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com>
|
||||
Copyright 2017 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
|
||||
@ -19,11 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<data>
|
||||
|
||||
<!-- Form -->
|
||||
<record id="view_form" model="ir.ui.view">
|
||||
<record id="golem_activity_registration_form_inherit_place" model="ir.ui.view">
|
||||
<field name="name">GOLEM Activity Places Form additions</field>
|
||||
<field name="model">golem.activity</field>
|
||||
<field name="inherit_id"
|
||||
ref="golem_activity_registration.activity_form" />
|
||||
ref="golem_activity_registration.golem_activity_form_inherit_registration" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="places" position="after">
|
||||
<field name="places_min" />
|
||||
@ -35,11 +35,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</record>
|
||||
|
||||
<!-- Tree -->
|
||||
<record id="tree" model="ir.ui.view">
|
||||
<record id="golem_activity_registration_tree_inherit_place" model="ir.ui.view">
|
||||
<field name="name">Activity list places adaptations</field>
|
||||
<field name="model">golem.activity</field>
|
||||
<field name="inherit_id"
|
||||
ref="golem_activity_registration.activity_tree" />
|
||||
ref="golem_activity_registration.golem_activity_tree_inherit_registration" />
|
||||
<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>
|
Loading…
Reference in New Issue
Block a user