From f77a93a1a2678ef21d31dec23b3fe75b98ed184e Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Tue, 20 Feb 2018 19:11:15 +0100 Subject: [PATCH] Add wizard to ask member about activity to register --- golem_activity_queue/__init__.py | 2 +- golem_activity_queue/__manifest__.py | 3 +- golem_activity_queue/models/golem_member.py | 9 ++-- .../views/golem_activity_queue_views.xml | 1 - golem_activity_queue/wizard/__init__.py | 19 ++++++++ .../wizard/golem_activity_queue_choose.py | 40 +++++++++++++++++ .../golem_activity_queue_choose_views.xml | 43 +++++++++++++++++++ 7 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 golem_activity_queue/wizard/__init__.py create mode 100644 golem_activity_queue/wizard/golem_activity_queue_choose.py create mode 100644 golem_activity_queue/wizard/golem_activity_queue_choose_views.xml diff --git a/golem_activity_queue/__init__.py b/golem_activity_queue/__init__.py index feff6f0..77cfa8b 100644 --- a/golem_activity_queue/__init__.py +++ b/golem_activity_queue/__init__.py @@ -15,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import models +from . import models, wizard diff --git a/golem_activity_queue/__manifest__.py b/golem_activity_queue/__manifest__.py index 48074e9..54d08e7 100644 --- a/golem_activity_queue/__manifest__.py +++ b/golem_activity_queue/__manifest__.py @@ -28,6 +28,7 @@ 'data': [ 'views/golem_activity_queue_views.xml', 'views/golem_activity_views.xml', - 'views/golem_member_views.xml' + 'views/golem_member_views.xml', + 'wizard/golem_activity_queue_choose_views.xml' ] } diff --git a/golem_activity_queue/models/golem_member.py b/golem_activity_queue/models/golem_member.py index 7b22394..bb9cb3c 100644 --- a/golem_activity_queue/models/golem_member.py +++ b/golem_activity_queue/models/golem_member.py @@ -24,6 +24,7 @@ class GolemMember(models.Model): @api.onchange('activity_registration_ids') def _checkRemain(self): + if len(self.activity_registration_ids) > self.places and self.queue_allowed: return { 'warning' : { @@ -33,11 +34,11 @@ class GolemMember(models.Model): } def queue_register(self): + return { - 'name' : _('Register in the queue'), + 'name' : _('Choose the activity to register in'), 'type' : 'ir.actions.act_window', - 'res_model' : 'golem.activity.queue', - 'view_mode': 'tree', - 'flags': {'action_buttons': True}, + 'res_model' : 'golem.activity.queue.choose.wizard', + 'view_mode': 'form',#'context' :{'default_activity_id' : activity_id.id},'domain' : [('activity_id.places_remain', '=', 0)],# activity_id.name)],#"('activity_id', '=', True)"'flags': {'action_buttons': True}, 'target': 'new', } diff --git a/golem_activity_queue/views/golem_activity_queue_views.xml b/golem_activity_queue/views/golem_activity_queue_views.xml index e286550..2f03b3c 100644 --- a/golem_activity_queue/views/golem_activity_queue_views.xml +++ b/golem_activity_queue/views/golem_activity_queue_views.xml @@ -47,7 +47,6 @@ along with this program. If not, see . - diff --git a/golem_activity_queue/wizard/__init__.py b/golem_activity_queue/wizard/__init__.py new file mode 100644 index 0000000..e7a0b4a --- /dev/null +++ b/golem_activity_queue/wizard/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_activity_queue_choose diff --git a/golem_activity_queue/wizard/golem_activity_queue_choose.py b/golem_activity_queue/wizard/golem_activity_queue_choose.py new file mode 100644 index 0000000..b325d60 --- /dev/null +++ b/golem_activity_queue/wizard/golem_activity_queue_choose.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# 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 the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Resources management """ + +from odoo import models, fields, api, _ + +class GolemActivityQueueChooseWizard(models.TransientModel): + """GOLEM Resource wizard : rchoose activity queue to register in """ + _name = "golem.activity.queue.choose.wizard" + + activity_id = fields.Many2one("golem.activity") + + def ChooseActivity(self): + self.ensure_one() + activityQueue = self[0] + return { + 'name' : _('Register in the queue'), + 'type' : 'ir.actions.act_window', + 'res_model' : 'golem.activity.queue', + 'view_mode': 'tree',#'context' :{'default_activity_id' : activity_id.id}, + 'domain' : [('activity_id', '=',activityQueue.activity_id.id )],# activity_id.name)],#"('activity_id', '=', True)" + 'flags': {'action_buttons': True}, + 'target': 'new', + } diff --git a/golem_activity_queue/wizard/golem_activity_queue_choose_views.xml b/golem_activity_queue/wizard/golem_activity_queue_choose_views.xml new file mode 100644 index 0000000..bd88b01 --- /dev/null +++ b/golem_activity_queue/wizard/golem_activity_queue_choose_views.xml @@ -0,0 +1,43 @@ + + + + + + + + + GOLEM Activity Queue Choose Wizard Form + golem.activity.queue.choose.wizard + +
+ + + + +
+
+
+ + +
+