forked from Yaltik/golem
[IMP]GOLEM Resource reservation rejection : enhance quality, use more common idioms
This commit is contained in:
parent
89319bd7e5
commit
661c7fecfe
@ -20,7 +20,7 @@
|
|||||||
'name': 'GOLEM non-profit resources',
|
'name': 'GOLEM non-profit resources',
|
||||||
'summary': 'GOLEM resources management',
|
'summary': 'GOLEM resources management',
|
||||||
'description': ''' GOLEM resources management ''',
|
'description': ''' GOLEM resources management ''',
|
||||||
'version': '10.0.1.0.2',
|
'version': '10.0.1.0.3',
|
||||||
'category': 'GOLEM',
|
'category': 'GOLEM',
|
||||||
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
'author': 'Youssef El Ouahby, Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
@ -16,30 +16,25 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
""" GOLEM Resources management """
|
||||||
|
|
||||||
from odoo import models, fields, api, _, exceptions
|
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 GolemResourceRejectionWizard(models.TransientModel):
|
||||||
class myWizard(models.TransientModel):
|
"""GOLEM Resource wizard : refusal reason for a reservation """
|
||||||
"""GOLEM Resource wizard"""
|
_name = "golem.resource.rejection.wizard"
|
||||||
_name = "golem.reourceswizard"
|
|
||||||
|
|
||||||
# recuperer la reservation courant
|
reservation_id = fields.Many2one('golem.reservation', required=True)
|
||||||
def _default_reservation(self):
|
reason = fields.Text(required=True)
|
||||||
return self.env['golem.reservation'].browse(self._context.get('active_id'))
|
|
||||||
|
|
||||||
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
|
#modèle de base : ressources
|
||||||
class GolemResources(models.Model):
|
class GolemResources(models.Model):
|
||||||
@ -108,16 +103,15 @@ class GolemReservation(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def status_rejected(self):
|
def status_rejected(self):
|
||||||
self.status = 'rejected'
|
""" Wizard call for reservation reject """
|
||||||
#lancement du wizard une fois l'administrateur rejet une reservation
|
self.ensure_one()
|
||||||
return {
|
reservation_id = self[0]
|
||||||
'name' : _('Please enter the reseaon of rejection'),
|
return {'name' : _('Please enter the rejection reason'),
|
||||||
'type' : 'ir.actions.act_window',
|
'type' : 'ir.actions.act_window',
|
||||||
'res_model' : 'golem.reourceswizard',
|
'res_model' : 'golem.resource.rejection.wizard',
|
||||||
|
'context': {'default_reservation_id': reservation_id.id},
|
||||||
'view_mode': 'form',
|
'view_mode': 'form',
|
||||||
'view_type': 'form',
|
'target': 'new'}
|
||||||
'target': 'new',
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@api.constrains('status')
|
@api.constrains('status')
|
||||||
|
@ -110,17 +110,22 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<field name="view_mode">tree,search,form,calendar</field>
|
<field name="view_mode">tree,search,form,calendar</field>
|
||||||
</record>
|
</record>
|
||||||
<menuitem id="resource_reservation_menu" name="Reservations"
|
<menuitem id="resource_reservation_menu" name="Reservations"
|
||||||
parent="resources_menu" action="action_resources" sequence="20" />
|
parent="resources_menu" action="action_reservation" sequence="20" />
|
||||||
|
|
||||||
<!--formulaire relatif au wizard du motif de refus-->
|
<record model="ir.ui.view" id="golem_resource_rejection_wizard_form_view">
|
||||||
<record model="ir.ui.view" id="wizard_form_view">
|
<field name="name">GOLEM Resource Rejection Wizard Form</field>
|
||||||
<field name="name">wizard.form</field>
|
<field name="model">golem.resource.rejection.wizard</field>
|
||||||
<field name="model">golem.reourceswizard</field>
|
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Add motif">
|
<form string="Rejection reason">
|
||||||
<group>
|
<group>
|
||||||
<field name="rejection_reason"/>
|
<field name="reservation_id" readonly="1" />
|
||||||
|
<field name="reason" />
|
||||||
</group>
|
</group>
|
||||||
|
<footer>
|
||||||
|
<button name="validate" string="Validate" type="object"
|
||||||
|
class="oe_highlight" />
|
||||||
|
<button string="Cancel" class="oe_link" special="cancel" />
|
||||||
|
</footer>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user