From 1967ab5ced19ae50781a0d26ca68ca7107601d3d Mon Sep 17 00:00:00 2001 From: eloyoussef Date: Wed, 21 Mar 2018 11:44:53 +0100 Subject: [PATCH] defintion de model pour selection et option --- golem_resource/models/golem_resource.py | 2 + .../models/golem_resource_option.py | 32 ++++++++++++++++ .../models/golem_resource_option_selection.py | 37 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 golem_resource/models/golem_resource_option.py create mode 100644 golem_resource/models/golem_resource_option_selection.py diff --git a/golem_resource/models/golem_resource.py b/golem_resource/models/golem_resource.py index fba69c5..b6f49e5 100644 --- a/golem_resource/models/golem_resource.py +++ b/golem_resource/models/golem_resource.py @@ -50,6 +50,8 @@ class GolemResource(models.Model): reservation_ids = fields.One2many('golem.resource.reservation', 'resource_id', string='Reservations') reservation_count = fields.Integer(compute='_compute_reservation_count') + option_ids = fields.One2many('golem.resource.option', 'resource_id', + string='Option list') @api.depends('reservation_ids') def _compute_reservation_count(self): diff --git a/golem_resource/models/golem_resource_option.py b/golem_resource/models/golem_resource_option.py new file mode 100644 index 0000000..b9905b9 --- /dev/null +++ b/golem_resource/models/golem_resource_option.py @@ -0,0 +1,32 @@ +# -*- 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 Resource Option """ + + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourceOption(models.Model): + """ GOLEM Resource Option Model """ + _name = 'golem.resource.option' + _description = 'GOLEM Reservation Model' + + name = fields.Char() + resource_id = fields.Many2one('golem.resource') diff --git a/golem_resource/models/golem_resource_option_selection.py b/golem_resource/models/golem_resource_option_selection.py new file mode 100644 index 0000000..64f3db8 --- /dev/null +++ b/golem_resource/models/golem_resource_option_selection.py @@ -0,0 +1,37 @@ +# -*- 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 Resource Option Selection""" + + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourceOptionSelection(models.Model): + """ GOLEM Resource Option SelectionModel """ + _name = 'golem.resource.option.selection' + _description = 'GOLEM Resource option selection Model' + + resource_id = fields.Many2one('golem.resource', 'Resource') + option_id = fields.Many2one('golem.resource.option', 'Option') + reservation_id = fields.Many2one('golem.resource.reservation', 'Reservation') + + _sql_constraints = [ + ('unique_selection', "UNIQUE(resource_id, option_id, reservation_id)", + _("Not allowed, a reservation with same option and resource already exists"))]