diff --git a/golem_activity_registration_state/i18n/fr.po b/golem_activity_registration_state/i18n/fr.po
index b17d1d8..ba9228b 100644
--- a/golem_activity_registration_state/i18n/fr.po
+++ b/golem_activity_registration_state/i18n/fr.po
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-07-31 17:51+0000\n"
-"PO-Revision-Date: 2018-07-31 17:51+0000\n"
+"POT-Creation-Date: 2018-08-01 11:37+0000\n"
+"PO-Revision-Date: 2018-08-01 13:43+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -25,11 +25,29 @@ msgstr "Activités"
msgid "Activity id"
msgstr "Activité liée"
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Are you sure you want to remove this subscription ?"
+msgstr "Êtes-vous sûr de vouloir supprimer cette inscription ?"
+
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Cancel"
+msgstr "Annuler"
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration,state:0
msgid "Canceled"
msgstr "Annulé"
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Confirm"
+msgstr "Confirmer"
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration,state:0
msgid "Confirmed"
@@ -137,6 +155,18 @@ msgstr "Prix"
msgid "Registration id"
msgstr "Registration id"
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Remove"
+msgstr "Supprimer"
+
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Reset to draft"
+msgstr "Remettre en brouillon"
+
#. module: golem_activity_registration_state
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_season_id
msgid "Season"
@@ -153,6 +183,13 @@ msgstr "État"
msgid "Validate all draft registrations"
msgstr "Valider toutes les inscriptions"
+#. module: golem_activity_registration_state
+#: code:addons/golem_activity_registration_state/models/golem_activity_registration.py:101
+#: code:addons/golem_activity_registration_state/models/golem_activity_registration.py:114
+#, python-format
+msgid "You can not confirm a canceled registration."
+msgstr "Vous ne pouvez pas confirmer une inscription qui a été annulée."
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration.invoicing,state:0
msgid "final"
diff --git a/golem_activity_registration_state/i18n/golem_activity_registration_state.pot b/golem_activity_registration_state/i18n/golem_activity_registration_state.pot
index 6147d08..c3c40b6 100644
--- a/golem_activity_registration_state/i18n/golem_activity_registration_state.pot
+++ b/golem_activity_registration_state/i18n/golem_activity_registration_state.pot
@@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-07-31 17:51+0000\n"
-"PO-Revision-Date: 2018-07-31 17:51+0000\n"
+"POT-Creation-Date: 2018-08-01 11:37+0000\n"
+"PO-Revision-Date: 2018-08-01 11:37+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@@ -25,11 +25,29 @@ msgstr ""
msgid "Activity id"
msgstr ""
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Are you sure you want to remove this subscription ?"
+msgstr ""
+
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Cancel"
+msgstr ""
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration,state:0
msgid "Canceled"
msgstr ""
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Confirm"
+msgstr ""
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration,state:0
msgid "Confirmed"
@@ -137,6 +155,18 @@ msgstr ""
msgid "Registration id"
msgstr ""
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Remove"
+msgstr ""
+
+#. module: golem_activity_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_activity_form_inherit_registration_state
+#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state
+msgid "Reset to draft"
+msgstr ""
+
#. module: golem_activity_registration_state
#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoicing_season_id
msgid "Season"
@@ -153,6 +183,13 @@ msgstr ""
msgid "Validate all draft registrations"
msgstr ""
+#. module: golem_activity_registration_state
+#: code:addons/golem_activity_registration_state/models/golem_activity_registration.py:101
+#: code:addons/golem_activity_registration_state/models/golem_activity_registration.py:114
+#, python-format
+msgid "You can not confirm a canceled registration."
+msgstr ""
+
#. module: golem_activity_registration_state
#: selection:golem.activity.registration.invoicing,state:0
msgid "final"
diff --git a/golem_activity_registration_state/models/golem_activity_registration.py b/golem_activity_registration_state/models/golem_activity_registration.py
index 5c23e36..fde5a1d 100644
--- a/golem_activity_registration_state/models/golem_activity_registration.py
+++ b/golem_activity_registration_state/models/golem_activity_registration.py
@@ -17,7 +17,8 @@
""" GOLEM Activity Registration State """
-from odoo import models, fields, api
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError
class GolemMember(models.Model):
""" GOLEM Member adaptations """
@@ -44,28 +45,6 @@ class GolemMember(models.Model):
lambda r: r.state == 'draft'
).write({'state': 'confirmed'})
- @api.multi
- def write(self, values):
- """ Handle removed activities to be canceled """
- if 'activity_registration_ids' in values:
- rids = values['activity_registration_ids']
- r_keep, r_removed = [], []
- for rid in rids: # == 2 is removal case
- if rid[0] == 2:
- r_removed.append(rid)
- else:
- r_keep.append(rid)
- reg_obj = self.env['golem.activity.registration']
- for rem in r_removed:
- reg = reg_obj.browse([rem[1]])
- # if already canceled, let it be removed, else cancel it
- if reg.state != 'canceled':
- reg.state = 'canceled'
- else:
- r_keep.append(rem)
- values['activity_registration_ids'] = r_keep
- return super(GolemMember, self).write(values)
-
class GolemActivity(models.Model):
""" GOLEM Activity adaptations """
@@ -88,6 +67,32 @@ class GolemActivityRegistration(models.Model):
('canceled', 'Canceled')], required=True,
default='draft')
+ @api.multi
+ def state_draft(self):
+ """ Set registration to state draft """
+ self.write({'state': 'draft'})
+
+ @api.multi
+ def state_confirm(self):
+ """ Set registration to state confirmed """
+ if self.filtered(lambda r: r.state == 'canceled'):
+ uerr = _('You can not confirm a canceled registration.')
+ raise UserError(uerr)
+ self.write({'state': 'confirmed'})
+
+ @api.multi
+ def state_cancel(self):
+ """ Set registration to state canceled """
+ self.write({'state': 'canceled'})
+
+ @api.multi
+ def state_remove(self):
+ """ Remove registrations, only if canceled """
+ if self.filtered(lambda r: r.state != 'canceled'):
+ uerr = _('You can not confirm a canceled registration.')
+ raise UserError(uerr)
+ self.unlink()
+
@api.multi
def write(self, values):
""" Recomputes values linked to registrations when state change """
diff --git a/golem_activity_registration_state/views/golem_activity_views.xml b/golem_activity_registration_state/views/golem_activity_views.xml
index 33f7189..8025738 100644
--- a/golem_activity_registration_state/views/golem_activity_views.xml
+++ b/golem_activity_registration_state/views/golem_activity_views.xml
@@ -26,15 +26,22 @@ along with this program. If not, see