forked from Yaltik/golem
[IMP]GOLEM Activity Registration State : small enhancements
* Reload client to reflect changes after unlink registration ; * Do no show buttons until registration has been saved.
This commit is contained in:
parent
661aabcfe8
commit
18957c4568
@ -19,7 +19,7 @@
|
||||
'name': 'GOLEM Activity Session Member Registrations States',
|
||||
'summary': 'GOLEM Activities Session Member Registration states',
|
||||
'description': 'GOLEM Activities Session Member Registration states',
|
||||
'version': '10.0.2.2.0',
|
||||
'version': '10.0.2.2.1',
|
||||
'category': 'GOLEM',
|
||||
'author': 'Fabien Bourgeois',
|
||||
'license': 'AGPL-3',
|
||||
|
@ -18,7 +18,7 @@
|
||||
""" GOLEM Activity Registration State """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
class GolemMember(models.Model):
|
||||
""" GOLEM Member adaptations """
|
||||
@ -89,9 +89,10 @@ class GolemActivityRegistration(models.Model):
|
||||
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.')
|
||||
uerr = _('You can not remove a uncanceled registration.')
|
||||
raise UserError(uerr)
|
||||
self.unlink()
|
||||
return {'type': 'ir.actions.client', 'tag': 'reload'}
|
||||
|
||||
@api.multi
|
||||
def write(self, values):
|
||||
|
@ -45,20 +45,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<attribute name="delete">0</attribute>
|
||||
</tree>
|
||||
<tree position="inside">
|
||||
<field name="id" invisible="1" />
|
||||
<field name="state" readonly="1" />
|
||||
<button type="object" name="state_draft" string="Reset to draft"
|
||||
icon="fa-arrow-up" attrs="{'invisible': [('state', '=', 'draft')]}"
|
||||
icon="fa-arrow-up" attrs="{'invisible': ['|', ('id', '=', False), ('state', '=', 'draft')]}"
|
||||
invisible="not context.get('action_show', 1)" />
|
||||
<button type="object" name="state_confirm" string="Confirm"
|
||||
icon="fa-check" attrs="{'invisible': [('state', '!=', 'draft')]}"
|
||||
icon="fa-check" attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'draft')]}"
|
||||
invisible="not context.get('action_show', 1)" />
|
||||
<button type="object" name="state_cancel" string="Cancel"
|
||||
icon="fa-ban" attrs="{'invisible': [('state', '=', 'canceled')]}"
|
||||
icon="fa-ban" attrs="{'invisible': ['|', ('id', '=', False), ('state', '=', 'canceled')]}"
|
||||
invisible="not context.get('action_show', 1)" />
|
||||
<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')]}"
|
||||
attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'canceled')]}"
|
||||
invisible="not context.get('action_show', 1)" />
|
||||
</tree>
|
||||
</field>
|
||||
|
Loading…
Reference in New Issue
Block a user