Creation du wizard pour la creation rapide des reservation

This commit is contained in:
eloyoussef 2018-04-19 13:54:15 +02:00
parent 460d138730
commit 1b6a3c674e
6 changed files with 110 additions and 2 deletions

View File

@ -20,7 +20,7 @@
'name': 'GOLEM resources pack',
'summary': 'GOLEM resources pack',
'description': ''' GOLEM resources pack ''',
'version': '10.0.0.0.5',
'version': '10.0.0.0.6',
'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3',
@ -29,5 +29,6 @@
'depends': ['golem_resource'],
'data': ['views/golem_resource_pack_views.xml',
'wizard/golem_pack_rejection_views.xml',
'wizard/golem_pack_quick_reservation_views.xml',
'security/ir.model.access.csv']
}

View File

@ -52,6 +52,18 @@ class GolemResourcePack(models.Model):
reservation_count = fields.Integer(compute='_compute_reservation_count')
rejection_reason = fields.Text(readonly=True, track_visibility='onchange')
@api.multi
def quick_reservation(self):
""" Quick Reservation Creating"""
self.ensure_one()
pack_id = self[0]
return {'name' : _('Reservations Creating'),
'type' : 'ir.actions.act_window',
'res_model' : 'golem.pack.quick.reservation.wizard',
'context': {'default_pack_id': pack_id.id},
'view_mode': 'form',
'target': 'new'}
@api.depends('reservation_ids')
def _compute_reservation_count(self):
for pack in self:

View File

@ -61,8 +61,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="user_id" />
<field name="partner_id" />
<field name="note" />
<field name="rejection_reason"
attrs="{'invisible': [('state', '!=', 'rejected')]}"/>
</group>
<group>
<button name="quick_reservation" type="object" string="Quick Reservation"
states="draft" class="oe_highlight"
/>
</group>
<group colspan="2" name="reservations">
<field name="reservation_ids" widget="many2many"

View File

@ -16,4 +16,4 @@
# 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/>.
from . import golem_pack_rejection
from . import golem_pack_rejection, golem_pack_quick_reservation

View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
#
# 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 <http://www.gnu.org/licenses/>.
""" GOLEM Pack Quick Reservation Wizard """
from odoo import models, fields, api
class GolemPackQuickReservationWizard(models.TransientModel):
"""GOLEM Pack Quick Reservation Wizard """
_name = "golem.pack.quick.reservation.wizard"
pack_id = fields.Many2one('golem.resource.pack', required=True)
resource_ids = fields.Many2many('golem.resource', string="Resource List")
date_start = fields.Datetime('Start date', required=True)
date_stop = fields.Datetime('Stop date', required=True)
@api.multi
def create_reservations(self):
""" Create a reservation for each resource """
pass
"""
self.ensure_one()
rdata = {'state': 'rejected',
'rejection_reason': self[0].reason}
self[0].pack_id.reservation_ids.filtered(lambda r: r.state == 'confirmed').write(rdata)
self[0].pack_id.rejection_reason = self[0].reason"""

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
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 <http://www.gnu.org/licenses/>.
-->
<odoo>
<data>
<!-- Forms -->
<record model="ir.ui.view" id="golem_pack_quick_reservation_wizard_view_form">
<field name="name">GOLEM Pack Quick Reservation Wizard Form</field>
<field name="model">golem.pack.quick.reservation.wizard</field>
<field name="arch" type="xml">
<form string="Quick Reservations">
<sheet>
<group>
<field name="pack_id" readonly="1" />
<field name="resource_ids" />
<field name="date_start" />
<field name="date_stop" />
</group>
</sheet>
<footer>
<button name="create_reservations" string="Create Reservations" type="object"
class="oe_highlight" />
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</data>
</odoo>