diff --git a/golem_ressources/__manifest__.py b/golem_ressources/__manifest__.py
index 00b2f04..f1a91f3 100644
--- a/golem_ressources/__manifest__.py
+++ b/golem_ressources/__manifest__.py
@@ -20,7 +20,7 @@
'name': 'GOLEM non-profit resources',
'summary': 'GOLEM resources management',
'description': ''' GOLEM resources management ''',
- 'version': '10.0.1.0.2',
+ 'version': '10.0.1.0.3',
'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3',
diff --git a/golem_ressources/models/golem_resources.py b/golem_ressources/models/golem_resources.py
index 28d7713..89acf7b 100644
--- a/golem_ressources/models/golem_resources.py
+++ b/golem_ressources/models/golem_resources.py
@@ -16,30 +16,25 @@
# 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, _, exceptions
-#Wizard pour recuperer le motif du refus d'une réservation et le stocker sur la reservation
-class myWizard(models.TransientModel):
- """GOLEM Resource wizard"""
- _name = "golem.reourceswizard"
+class GolemResourceRejectionWizard(models.TransientModel):
+ """GOLEM Resource wizard : refusal reason for a reservation """
+ _name = "golem.resource.rejection.wizard"
- # recuperer la reservation courant
- def _default_reservation(self):
- return self.env['golem.reservation'].browse(self._context.get('active_id'))
+ reservation_id = fields.Many2one('golem.reservation', required=True)
+ reason = fields.Text(required=True)
- rejection_reason = fields.Text()
+ @api.multi
+ def validate(self, vals):
+ """ Sets reservation status to rejected and add reason """
+ self.ensure_one()
+ rejection = self[0]
+ rejection.reservation_id.write({'status': 'rejected',
+ 'rejection_reason': rejection.reason})
- #override la methode d'ecriture de wizard pour stocker le motif du refus sur la reservation
- @api.model
- def create(self, vals):
- #récuperation de la reservation actuelle
- record = self.env['golem.reservation'].browse(self._context.get('active_id'))
- #stockage du motif sur la reservation
- record.rejection_reason = vals['rejection_reason']
- new_record = super(myWizard, self).create(vals)
- return new_record
#modèle de base : ressources
class GolemResources(models.Model):
@@ -108,16 +103,15 @@ class GolemReservation(models.Model):
@api.multi
def status_rejected(self):
- self.status = 'rejected'
- #lancement du wizard une fois l'administrateur rejet une reservation
- return {
- 'name' : _('Please enter the reseaon of rejection'),
- 'type' : 'ir.actions.act_window',
- 'res_model' : 'golem.reourceswizard',
+ """ Wizard call for reservation reject """
+ self.ensure_one()
+ reservation_id = self[0]
+ return {'name' : _('Please enter the rejection reason'),
+ 'type' : 'ir.actions.act_window',
+ 'res_model' : 'golem.resource.rejection.wizard',
+ 'context': {'default_reservation_id': reservation_id.id},
'view_mode': 'form',
- 'view_type': 'form',
- 'target': 'new',
- }
+ 'target': 'new'}
@api.constrains('status')
diff --git a/golem_ressources/views/golem_reservation_views.xml b/golem_ressources/views/golem_reservation_views.xml
index 1a968d5..8ece16c 100644
--- a/golem_ressources/views/golem_reservation_views.xml
+++ b/golem_ressources/views/golem_reservation_views.xml
@@ -110,17 +110,22 @@ along with this program. If not, see .
tree,search,form,calendar
+ parent="resources_menu" action="action_reservation" sequence="20" />
-
-
- wizard.form
- golem.reourceswizard
+
+ GOLEM Resource Rejection Wizard Form
+ golem.resource.rejection.wizard
-