fonction de creation des reservation

This commit is contained in:
eloyoussef 2018-04-19 14:54:43 +02:00
parent 1b6a3c674e
commit 0b97623c02
4 changed files with 15 additions and 8 deletions

View File

@ -20,7 +20,7 @@
'name': 'GOLEM resources pack', 'name': 'GOLEM resources pack',
'summary': 'GOLEM resources pack', 'summary': 'GOLEM resources pack',
'description': ''' GOLEM resources pack ''', 'description': ''' GOLEM resources pack ''',
'version': '10.0.0.0.6', 'version': '10.0.0.0.7',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois', 'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -60,7 +60,8 @@ class GolemResourcePack(models.Model):
return {'name' : _('Reservations Creating'), return {'name' : _('Reservations Creating'),
'type' : 'ir.actions.act_window', 'type' : 'ir.actions.act_window',
'res_model' : 'golem.pack.quick.reservation.wizard', 'res_model' : 'golem.pack.quick.reservation.wizard',
'context': {'default_pack_id': pack_id.id}, 'context': {'default_pack_id': pack_id.id,
'default_partner_id': pack_id.partner_id.id},
'view_mode': 'form', 'view_mode': 'form',
'target': 'new'} 'target': 'new'}

View File

@ -25,6 +25,7 @@ class GolemPackQuickReservationWizard(models.TransientModel):
_name = "golem.pack.quick.reservation.wizard" _name = "golem.pack.quick.reservation.wizard"
pack_id = fields.Many2one('golem.resource.pack', required=True) pack_id = fields.Many2one('golem.resource.pack', required=True)
partner_id = fields.Many2one('res.partner', string='On behalf of', readonly=True)
resource_ids = fields.Many2many('golem.resource', string="Resource List") resource_ids = fields.Many2many('golem.resource', string="Resource List")
date_start = fields.Datetime('Start date', required=True) date_start = fields.Datetime('Start date', required=True)
@ -34,10 +35,14 @@ class GolemPackQuickReservationWizard(models.TransientModel):
@api.multi @api.multi
def create_reservations(self): def create_reservations(self):
""" Create a reservation for each resource """ """ Create a reservation for each resource """
pass
"""
self.ensure_one() self.ensure_one()
rdata = {'state': 'rejected', wizard = self[0]
'rejection_reason': self[0].reason} data = []
self[0].pack_id.reservation_ids.filtered(lambda r: r.state == 'confirmed').write(rdata) for resource in wizard.resource_ids:
self[0].pack_id.rejection_reason = self[0].reason""" reservation = {'user_id': self.env.user,
'partner_id': wizard.partner_id,
'resource_id': resource,
'date_start': wizard.date_start,
'date_stop': wizard.date_stop}
data.append((0, 0, reservation))
wizard.pack_id.reservation_ids = data

View File

@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<sheet> <sheet>
<group> <group>
<field name="pack_id" readonly="1" /> <field name="pack_id" readonly="1" />
<field name="partner_id" readonly="1"/>
<field name="resource_ids" /> <field name="resource_ids" />
<field name="date_start" /> <field name="date_start" />
<field name="date_stop" /> <field name="date_stop" />