[REF][ADD]GOLEM Registration State : individual confirm, draft, cancel, removals
This commit is contained in:
parent
ce55580bf7
commit
4a2de70755
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 """
|
||||
|
@ -26,15 +26,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<field name="inherit_id"
|
||||
ref="golem_activity_registration.golem_activity_form_inherit_registration" />
|
||||
<field name="arch" type="xml">
|
||||
<tree position="replace">
|
||||
<tree editable="top"
|
||||
colors="red: state == 'canceled';darkgrey: state == 'draft';">
|
||||
<field name="state" invisible="1" />
|
||||
<field name="member_id"
|
||||
domain="[('season_ids', '=', season_id)]" />
|
||||
<field name="activity_id" readonly="1" />
|
||||
<field name="season_id" readonly="1" />
|
||||
</tree>
|
||||
<tree position="attributes">
|
||||
<attribute name="colors">darkgrey: state == 'canceled';blue: state == 'confirmed';</attribute>
|
||||
<attribute name="delete">0</attribute>
|
||||
</tree>
|
||||
<tree position="inside">
|
||||
<field name="state" />
|
||||
<button type="object" name="state_draft" string="Reset to draft"
|
||||
icon="fa-arrow-up" attrs="{'invisible': [('state', '=', 'draft')]}" />
|
||||
<button type="object" name="state_confirm" string="Confirm"
|
||||
icon="fa-check" attrs="{'invisible': [('state', '!=', 'draft')]}" />
|
||||
<button type="object" name="state_cancel" string="Cancel"
|
||||
icon="fa-ban" attrs="{'invisible': [('state', '=', 'canceled')]}" />
|
||||
<button type="object" name="state_remove" string="Remove"
|
||||
icon="fa-trash"
|
||||
confirm="Are you sure you want to remove this subscription ?"
|
||||
attrs="{'invisible': [('state', '!=', 'canceled')]}" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -39,14 +39,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
attrs="{'invisible': [('has_draft_registrations', '=', False)]}" />
|
||||
</p>
|
||||
</field>
|
||||
<!-- TODO : one by one cancelation -->
|
||||
<!-- TODO : do not allow removal if confirmed -->
|
||||
<tree position="attributes">
|
||||
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
|
||||
</tree>
|
||||
<tree position="inside">
|
||||
<field name="state" invisible="1" />
|
||||
</tree>
|
||||
<xpath expr="//field[@name='activity_registration_ids']/tree" position="attributes">
|
||||
<attribute name="colors">darkgrey: state == 'canceled';blue: state == 'confirmed';</attribute>
|
||||
<attribute name="delete">0</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='activity_registration_ids']/tree" position="inside">
|
||||
<field name="state" />
|
||||
<button type="object" name="state_draft" string="Reset to draft"
|
||||
icon="fa-arrow-up" attrs="{'invisible': [('state', '=', 'draft')]}" />
|
||||
<button type="object" name="state_confirm" string="Confirm"
|
||||
icon="fa-check" attrs="{'invisible': [('state', '!=', 'draft')]}" />
|
||||
<button type="object" name="state_cancel" string="Cancel"
|
||||
icon="fa-ban" attrs="{'invisible': [('state', '=', 'canceled')]}" />
|
||||
<button type="object" name="state_remove" string="Remove"
|
||||
icon="fa-trash"
|
||||
confirm="Are you sure you want to remove this subscription ?"
|
||||
attrs="{'invisible': [('state', '!=', 'canceled')]}" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='activity_registration_all_ids']/tree" position="attributes">
|
||||
<attribute name="colors">darkgrey: state == 'canceled';blue: state == 'confirmed';</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='activity_registration_all_ids']/tree" position="inside">
|
||||
<field name="state" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user