2018-02-07 01:44:48 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2018-02-18 07:27:32 +01:00
|
|
|
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
|
|
|
|
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
2018-02-07 01:44:48 +01:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2018-02-18 08:20:39 +01:00
|
|
|
""" GOLEM Resources management """
|
2018-02-07 01:44:48 +01:00
|
|
|
|
2018-02-18 14:10:30 +01:00
|
|
|
from odoo import models, fields, api
|
2018-02-10 00:05:36 +01:00
|
|
|
|
2018-02-14 13:44:37 +01:00
|
|
|
|
2018-02-18 12:25:11 +01:00
|
|
|
class GolemResource(models.Model):
|
|
|
|
""" GOLEM Resource Model """
|
|
|
|
_name = 'golem.resource'
|
|
|
|
_description = 'GOLEM Resource Model'
|
2018-02-18 17:30:11 +01:00
|
|
|
_inherit = 'mail.thread'
|
2018-02-18 17:36:01 +01:00
|
|
|
_order = 'name asc'
|
2018-02-07 01:44:48 +01:00
|
|
|
|
2018-02-18 12:25:11 +01:00
|
|
|
name = fields.Char(required=True, index=True)
|
2018-02-08 23:21:33 +01:00
|
|
|
active = fields.Boolean(default=True)
|
2018-02-18 12:25:11 +01:00
|
|
|
validation_required = fields.Boolean(default=True,
|
|
|
|
string='Is validation required ?')
|
|
|
|
type_id = fields.Many2one('golem.resource.type',
|
|
|
|
index=True, string='Resource Type')
|
|
|
|
supervisor_id = fields.Many2one('res.partner', index=True, string='Supervisor')
|
|
|
|
product_tmpl_id = fields.Many2one('product.template', index=True,
|
2018-02-18 14:53:53 +01:00
|
|
|
string='Linked product',
|
|
|
|
help='A generic product can be linked, in '
|
|
|
|
'order to sell reservations (work in '
|
|
|
|
'progress)')
|
2018-02-18 12:25:11 +01:00
|
|
|
|
|
|
|
avaibility_start = fields.Date(required=True, string='Availibility start date')
|
|
|
|
avaibility_stop = fields.Date(required=True, string='Availibility stop date')
|
|
|
|
timetable_ids = fields.One2many('golem.resource.timetable', 'resource_id',
|
|
|
|
string='Availibility timetable')
|
|
|
|
reservation_ids = fields.One2many('golem.resource.reservation', 'resource_id',
|
|
|
|
string='Reservations')
|
2018-02-07 18:13:02 +01:00
|
|
|
|
|
|
|
@api.multi
|
2018-02-18 12:25:11 +01:00
|
|
|
def active_toggle(self):
|
|
|
|
""" Toggles active boolean """
|
|
|
|
for resource in self:
|
|
|
|
resource.active = not resource.active
|