[IMP]GOLEM Activity Session Registrations simplification : no state handling per default
This commit is contained in:
parent
d13f19aed9
commit
30ddbbccc2
@ -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-09-22 11:49+0000\n"
|
"POT-Creation-Date: 2016-10-10 09:08+0000\n"
|
||||||
"PO-Revision-Date: 2016-09-22 11:49+0000\n"
|
"PO-Revision-Date: 2016-10-10 09:08+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -17,7 +17,7 @@ msgstr ""
|
|||||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: view:golem.member:golem_activity_session_registration.sessions_inscription
|
#: view:golem.member:golem_activity_session_registration.sessions_registration
|
||||||
#: field:golem.member,activity_session_registration_ids:0
|
#: field:golem.member,activity_session_registration_ids:0
|
||||||
msgid "Activities"
|
msgid "Activities"
|
||||||
msgstr "Activités"
|
msgstr "Activités"
|
||||||
@ -48,7 +48,7 @@ msgid "Default season"
|
|||||||
msgstr "Saison par défaut"
|
msgstr "Saison par défaut"
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: view:golem.member:golem_activity_session_registration.sessions_inscription
|
#: view:golem.member:golem_activity_session_registration.sessions_registration
|
||||||
msgid "Default season activities"
|
msgid "Default season activities"
|
||||||
msgstr "Activités de la saison affichée par défaut"
|
msgstr "Activités de la saison affichée par défaut"
|
||||||
|
|
||||||
@ -112,6 +112,16 @@ msgstr "Dernière mise à jour par"
|
|||||||
msgid "Last Updated on"
|
msgid "Last Updated on"
|
||||||
msgstr "Mis à jour pour la dernière fois le"
|
msgstr "Mis à jour pour la dernière fois le"
|
||||||
|
|
||||||
|
#. module: golem_activity_session_registration
|
||||||
|
#: sql_constraint:golem.activity.session.registration:0
|
||||||
|
msgid "Le membre a déjà été inscrit à cette séance."
|
||||||
|
msgstr "Le membre a déjà été inscrit à cette séance."
|
||||||
|
|
||||||
|
#. module: golem_activity_session_registration
|
||||||
|
#: sql_constraint:golem.activity.session:0
|
||||||
|
msgid "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_registration
|
#. module: golem_activity_session_registration
|
||||||
#: field:golem.activity.session.registration,member_id:0
|
#: field:golem.activity.session.registration,member_id:0
|
||||||
msgid "Member"
|
msgid "Member"
|
||||||
@ -125,7 +135,6 @@ msgstr "Adhérents"
|
|||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32
|
||||||
#: sql_constraint:golem.activity.session:0
|
|
||||||
#, 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"
|
||||||
@ -177,14 +186,13 @@ msgid "Subscription"
|
|||||||
msgstr "Inscription"
|
msgstr "Inscription"
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:91
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:90
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Subscription can not be executed : the targeted member is not on the same season as the session."
|
msgid "Subscription can not be executed : the targeted member is not on the same season as the session."
|
||||||
msgstr "L'inscription n'a pas pu être enregistrée : le membre visé n'est pas ahdérant pour la même saison que celle pendant laquelle se déroule la séance."
|
msgstr "L'inscription n'a pas pu être enregistrée : le membre visé n'est pas ahdérant pour la même saison que celle pendant laquelle se déroule la séance."
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:83
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:82
|
||||||
#: sql_constraint:golem.activity.session.registration:0
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "This member has already been registered for this session."
|
msgid "This member has already been registered for this session."
|
||||||
msgstr "Le membre a déjà été inscrit à cette séance."
|
msgstr "Le membre a déjà été inscrit à cette séance."
|
||||||
|
@ -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-09-22 11:49+0000\n"
|
"POT-Creation-Date: 2016-10-10 09:08+0000\n"
|
||||||
"PO-Revision-Date: 2016-09-22 11:49+0000\n"
|
"PO-Revision-Date: 2016-10-10 09:08+0000\n"
|
||||||
"Last-Translator: <>\n"
|
"Last-Translator: <>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
@ -16,7 +16,7 @@ msgstr ""
|
|||||||
"Plural-Forms: \n"
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: view:golem.member:golem_activity_session_registration.sessions_inscription
|
#: view:golem.member:golem_activity_session_registration.sessions_registration
|
||||||
#: field:golem.member,activity_session_registration_ids:0
|
#: field:golem.member,activity_session_registration_ids:0
|
||||||
msgid "Activities"
|
msgid "Activities"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -47,7 +47,7 @@ msgid "Default season"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: view:golem.member:golem_activity_session_registration.sessions_inscription
|
#: view:golem.member:golem_activity_session_registration.sessions_registration
|
||||||
msgid "Default season activities"
|
msgid "Default season activities"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -111,6 +111,16 @@ msgstr ""
|
|||||||
msgid "Last Updated on"
|
msgid "Last Updated on"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: golem_activity_session_registration
|
||||||
|
#: sql_constraint:golem.activity.session.registration:0
|
||||||
|
msgid "Le membre a déjà été inscrit à cette séance."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: golem_activity_session_registration
|
||||||
|
#: sql_constraint:golem.activity.session:0
|
||||||
|
msgid "Le nombre de places ne peut pas être négatif"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: field:golem.activity.session.registration,member_id:0
|
#: field:golem.activity.session.registration,member_id:0
|
||||||
msgid "Member"
|
msgid "Member"
|
||||||
@ -124,7 +134,6 @@ msgstr ""
|
|||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32
|
||||||
#: sql_constraint:golem.activity.session:0
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Number of places cannot be negative."
|
msgid "Number of places cannot be negative."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -176,14 +185,13 @@ msgid "Subscription"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:91
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:90
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Subscription can not be executed : the targeted member is not on the same season as the session."
|
msgid "Subscription can not be executed : the targeted member is not on the same season as the session."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: golem_activity_session_registration
|
#. module: golem_activity_session_registration
|
||||||
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:83
|
#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:82
|
||||||
#: sql_constraint:golem.activity.session.registration:0
|
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "This member has already been registered for this session."
|
msgid "This member has already been registered for this session."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -23,45 +23,6 @@ class GolemMember(models.Model):
|
|||||||
|
|
||||||
activity_session_registration_ids = fields.One2many(
|
activity_session_registration_ids = fields.One2many(
|
||||||
'golem.activity.session.registration', 'member_id', 'Activities')
|
'golem.activity.session.registration', 'member_id', 'Activities')
|
||||||
has_draft_registrations = fields.Boolean(
|
|
||||||
'Has draft registrations ?',
|
|
||||||
compute='_compute_has_draft_registrations')
|
|
||||||
|
|
||||||
@api.one
|
|
||||||
@api.depends('activity_session_registration_ids')
|
|
||||||
def _compute_has_draft_registrations(self):
|
|
||||||
""" Check if there are draft states in member activities """
|
|
||||||
for r in self.activity_session_registration_ids:
|
|
||||||
if r.state == 'draft':
|
|
||||||
self.has_draft_registrations = True
|
|
||||||
return
|
|
||||||
self.has_draft_registrations = False
|
|
||||||
|
|
||||||
@api.one
|
|
||||||
def do_validate_registrations(self):
|
|
||||||
""" Validate all draft registrations """
|
|
||||||
draft_registrations = self.activity_session_registration_ids.filtered(
|
|
||||||
lambda r: r.state == 'draft')
|
|
||||||
draft_registrations.write({'state': 'confirmed'})
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def write(self, values):
|
|
||||||
""" Handle removed activities to be canceled """
|
|
||||||
if 'activity_session_registration_ids' in values:
|
|
||||||
rids = values['activity_session_registration_ids']
|
|
||||||
r_keep, r_removed = [], []
|
|
||||||
for r in rids: # == 2 is removal case
|
|
||||||
r_removed.append(r) if r[0] == 2 else r_keep.append(r)
|
|
||||||
rObj = self.env['golem.activity.session.registration']
|
|
||||||
for rem in r_removed:
|
|
||||||
r = rObj.browse([rem[1]])
|
|
||||||
# if already canceled, let it be removed, else cancel it
|
|
||||||
if r.state != 'canceled':
|
|
||||||
r.state = 'canceled'
|
|
||||||
else:
|
|
||||||
r_keep.append(rem)
|
|
||||||
values['activity_session_registration_ids'] = r_keep
|
|
||||||
return super(GolemMember, self).write(values)
|
|
||||||
|
|
||||||
|
|
||||||
class GolemActivitySession(models.Model):
|
class GolemActivitySession(models.Model):
|
||||||
@ -78,8 +39,7 @@ class GolemActivitySession(models.Model):
|
|||||||
@api.one
|
@api.one
|
||||||
@api.depends('activity_session_registration_ids')
|
@api.depends('activity_session_registration_ids')
|
||||||
def _compute_places_used(self):
|
def _compute_places_used(self):
|
||||||
rids = self.activity_session_registration_ids
|
self.places_used = len(self.activity_session_registration_ids)
|
||||||
self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed'))
|
|
||||||
|
|
||||||
places = fields.Integer('Places', default=20)
|
places = fields.Integer('Places', default=20)
|
||||||
places_remain = fields.Integer('Remaining places', store=True,
|
places_remain = fields.Integer('Remaining places', store=True,
|
||||||
@ -103,9 +63,6 @@ class GolemActivitySessionRegistration(models.Model):
|
|||||||
_name = 'golem.activity.session.registration'
|
_name = 'golem.activity.session.registration'
|
||||||
_description = 'GOLEM Activity Session Registration'
|
_description = 'GOLEM Activity Session Registration'
|
||||||
|
|
||||||
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'),
|
|
||||||
('canceled', 'Canceled')], required=True,
|
|
||||||
default='draft')
|
|
||||||
member_id = fields.Many2one('golem.member', string='Member', required=True,
|
member_id = fields.Many2one('golem.member', string='Member', required=True,
|
||||||
ondelete='cascade')
|
ondelete='cascade')
|
||||||
session_id = fields.Many2one('golem.activity.session', required=True,
|
session_id = fields.Many2one('golem.activity.session', required=True,
|
||||||
@ -133,12 +90,3 @@ class GolemActivitySessionRegistration(models.Model):
|
|||||||
emsg = _('Subscription can not be executed : the targeted '
|
emsg = _('Subscription can not be executed : the targeted '
|
||||||
'member is not on the same season as the session.')
|
'member is not on the same season as the session.')
|
||||||
raise models.ValidationError(emsg)
|
raise models.ValidationError(emsg)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def write(self, values):
|
|
||||||
""" Recomputes values linked to registrations when state change """
|
|
||||||
res = super(GolemActivitySessionRegistration, self).write(values)
|
|
||||||
if values['state']:
|
|
||||||
for r in self:
|
|
||||||
r.session_id._compute_places_used()
|
|
||||||
return res
|
|
||||||
|
@ -40,9 +40,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="name">Session registration list</field>
|
<field name="name">Session registration list</field>
|
||||||
<field name="model">golem.activity.session.registration</field>
|
<field name="model">golem.activity.session.registration</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree create="true" edit="false" delete="false" editable="top"
|
<tree create="true" edit="false" delete="false" editable="top">
|
||||||
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
|
||||||
<field name="state" invisible="1" />
|
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
<field name="member_id" domain="[('is_current', '=', True)]" />
|
<field name="member_id" domain="[('is_current', '=', True)]" />
|
||||||
<field name="session_id" domain="[('is_current', '=', True)]" />
|
<field name="session_id" domain="[('is_current', '=', True)]" />
|
||||||
|
@ -33,9 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="places_remain" readonly="True" />
|
<field name="places_remain" readonly="True" />
|
||||||
<field name="activity_session_registration_ids"
|
<field name="activity_session_registration_ids"
|
||||||
context="{'default_session_id': active_id}">
|
context="{'default_session_id': active_id}">
|
||||||
<tree editable="top"
|
<tree editable="top">
|
||||||
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
|
||||||
<field name="state" invisible="1" />
|
|
||||||
<field name="member_id"
|
<field name="member_id"
|
||||||
domain="[('season_ids', '=', season_id)]" />
|
domain="[('season_ids', '=', season_id)]" />
|
||||||
<field name="session_id" readonly="1" />
|
<field name="session_id" readonly="1" />
|
||||||
|
@ -19,35 +19,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<data>
|
<data>
|
||||||
|
|
||||||
<!-- Form -->
|
<!-- Form -->
|
||||||
<record model="ir.ui.view" id="sessions_inscription">
|
<record model="ir.ui.view" id="sessions_registration">
|
||||||
<field name="name">Add sessions inscriptions to member form</field>
|
<field name="name">Add sessions registrations to member form</field>
|
||||||
<field name="model">golem.member</field>
|
<field name="model">golem.member</field>
|
||||||
<field name="inherit_id" ref="golem_member.view_form" />
|
<field name="inherit_id" ref="golem_member.view_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<page name="other_page" position="before">
|
<page name="other_page" position="before">
|
||||||
<page name="sessions" string="Activities">
|
<page name="sessions" string="Activities">
|
||||||
|
<p name="default_season_label">Default season activities</p>
|
||||||
<field name="id" invisible="1" />
|
<field name="id" invisible="1" />
|
||||||
<p>Default season activities</p>
|
|
||||||
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">
|
|
||||||
Note that you can't register activities if the member is new and not yet saved into the database.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<field name="has_draft_registrations" invisible="1" />
|
|
||||||
<button name="do_validate_registrations" type="object"
|
|
||||||
string="Validate all draft registrations"
|
|
||||||
class="oe_highlight"
|
|
||||||
help="If you validate draft registration, they will be seen as confirmed. Then, an invoice will be created for the current member."
|
|
||||||
attrs="{'invisible': [('has_draft_registrations', '=', False)]}" />
|
|
||||||
<!-- TODO : one by one cancelation -->
|
|
||||||
<!-- TODO : do not allow removal if confirmed -->
|
|
||||||
</p>
|
|
||||||
<group>
|
<group>
|
||||||
<field name="activity_session_registration_ids"
|
<field name="activity_session_registration_ids"
|
||||||
attrs="{'readonly': [('id', '=', False)]}"
|
attrs="{'readonly': [('id', '=', False)]}"
|
||||||
context="{'default_member_id': active_id}">
|
context="{'default_member_id': active_id}">
|
||||||
<tree editable="top"
|
<tree editable="top">
|
||||||
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
|
||||||
<field name="state" invisible="1" />
|
|
||||||
<field name="session_id"
|
<field name="session_id"
|
||||||
domain="[('is_current', '=', True)]" />
|
domain="[('is_current', '=', True)]" />
|
||||||
<field name="season_id" readonly="1" />
|
<field name="season_id" readonly="1" />
|
||||||
|
Loading…
Reference in New Issue
Block a user