diff --git a/golem_resource/views/golem_resource_views.xml b/golem_resource/views/golem_resource_views.xml
index 48331c9..d723f68 100644
--- a/golem_resource/views/golem_resource_views.xml
+++ b/golem_resource/views/golem_resource_views.xml
@@ -68,24 +68,28 @@ along with this program. If not, see .
-
-
-
-
-
-
-
-
- Please save the resource before fixing the timetable availability"
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ Please save the resource before fixing the timetable availability"
+
+
+
+
+
+
+
diff --git a/golem_resource_holiday/__init__.py b/golem_resource_holiday/__init__.py
new file mode 100644
index 0000000..3c60092
--- /dev/null
+++ b/golem_resource_holiday/__init__.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Youssef El Ouahby
+# Copyright 2020 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 .
+
+from . import models
diff --git a/golem_resource_holiday/__manifest__.py b/golem_resource_holiday/__manifest__.py
new file mode 100644
index 0000000..5076c1c
--- /dev/null
+++ b/golem_resource_holiday/__manifest__.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Youssef El Ouahby
+# Copyright 2020 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 .
+
+{
+ 'name': 'GOLEM resources holiday',
+ 'summary': 'GOLEM resources holiday',
+ 'description': ''' GOLEM resources holiday ''',
+ 'version': '10.0.0.0.1',
+ 'category': 'GOLEM',
+ 'author': 'Youssef El Ouahby, Fabien Bourgeois',
+ 'license': 'AGPL-3',
+ 'application': True,
+ 'installable': True,
+ 'depends': ['golem_resource'],
+ 'data': [
+ #security
+ 'security/ir.model.access.csv',
+ #views
+ 'views/golem_resource_views.xml',
+ 'views/golem_resource_holiday_views.xml',
+ 'views/golem_resource_holiday_period_views.xml'
+ ]
+}
diff --git a/golem_resource_holiday/models/__init__.py b/golem_resource_holiday/models/__init__.py
new file mode 100644
index 0000000..fc1cacc
--- /dev/null
+++ b/golem_resource_holiday/models/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 .
+
+
+from . import ( golem_resource_holiday, golem_resource_holiday_period,
+ golem_resource, golem_resource_holiday_selection,
+ golem_resource_reservation)
diff --git a/golem_resource_holiday/models/golem_resource.py b/golem_resource_holiday/models/golem_resource.py
new file mode 100644
index 0000000..95a51ae
--- /dev/null
+++ b/golem_resource_holiday/models/golem_resource.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 Resources Adaptations """
+
+from odoo import models, fields, api, _
+
+
+class GolemResource(models.Model):
+ """ GOLEM Resource Model """
+ _inherit = 'golem.resource'
+
+ holiday_period_ids = fields.Many2many('golem.resource.holiday.period', string='Holiday period list')
+
+ holiday_selection_ids = fields.One2many('golem.resource.holiday.selection', 'resource_id',
+ string='Holiday selection')
+
+ @api.constrains('holiday_period_ids')
+ def synchronise_holiday_selection(self):
+ """ Synchronise holiday selection """
+ for resource in self:
+ period_ids = resource.holiday_period_ids.ids
+
+ #compute selections 2 remove from list if any
+ self.env['golem.resource.holiday.selection'].search([
+ ('resource_id', '=', resource.id),
+ ('period_id', 'not in', period_ids)
+ ]).unlink()
+ #selection_2_remove.unlink()
+
+ #compute selection to add to list if any
+ if resource.holiday_period_ids:
+ existing_holiday = self.env['golem.resource.holiday.selection'].search([
+ ('resource_id', '=', resource.id)]).mapped('holiday_id')
+ holiday_2_add = self.env['golem.resource.holiday'].search([
+ ('period_id', 'in', period_ids)]) - existing_holiday
+
+ for holiday in holiday_2_add:
+ self.env['golem.resource.holiday.selection'].create({
+ 'holiday_id' : holiday.id,
+ 'resource_id': resource.id,
+ })
diff --git a/golem_resource_holiday/models/golem_resource_holiday.py b/golem_resource_holiday/models/golem_resource_holiday.py
new file mode 100644
index 0000000..0ddae15
--- /dev/null
+++ b/golem_resource_holiday/models/golem_resource_holiday.py
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 holiday Management"""
+
+from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
+
+
+class GolemResourceHoliday(models.Model):
+ """ GOLEM Resource Holiday Management """
+ _name = 'golem.resource.holiday'
+ _description = 'GOLEM Resource Holiday Managementl'
+ _inherit = 'mail.thread'
+ _order = 'name asc'
+
+ name = fields.Char(compute='_compute_name', store=True)
+ period_id = fields.Many2one('golem.resource.holiday.period', string='Holiday period',
+ ondelete='cascade')
+ date_start = fields.Date('Holiday start')
+ date_end = fields.Date('Holiday end')
+
+ @api.depends('period_id', 'date_start', 'date_end')
+ def _compute_name(self):
+ """ Computes holiday name """
+ for holiday in self:
+ holiday.name = u'{}/{}:{}'.format(holiday.period_id.name,
+ holiday.date_start,
+ holiday.date_end)
+
+ @api.constrains('date_start', 'date_end')
+ def _check_date_consistency(self):
+ """ Checks date consistency """
+ for holiday in self:
+ if holiday.date_end <= holiday.date_start:
+ raise ValidationError(_('Date end should be after than '
+ 'date start'))
diff --git a/golem_resource_holiday/models/golem_resource_holiday_period.py b/golem_resource_holiday/models/golem_resource_holiday_period.py
new file mode 100644
index 0000000..bc9756b
--- /dev/null
+++ b/golem_resource_holiday/models/golem_resource_holiday_period.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 holiday period Management """
+
+from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
+
+
+class GolemResourceHolidayPeriod(models.Model):
+ """ GOLEM Resource Holiday Period """
+ _name = 'golem.resource.holiday.period'
+ _description = 'GOLEM Resource Holiday Period Managementl'
+ _inherit = 'mail.thread'
+ _order = 'name asc'
+
+ name = fields.Char(required=True, index=True)
+ active = fields.Boolean(default=True)
diff --git a/golem_resource_holiday/models/golem_resource_holiday_selection.py b/golem_resource_holiday/models/golem_resource_holiday_selection.py
new file mode 100644
index 0000000..b303bd8
--- /dev/null
+++ b/golem_resource_holiday/models/golem_resource_holiday_selection.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 Holiday Selection Management """
+
+from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
+
+
+class GolemResourceHolidaySelection(models.Model):
+ """ GOLEM Resource Holiday Selection"""
+ _name = 'golem.resource.holiday.selection'
+ _description = 'GOLEM Resource Holiday Selection Management'
+
+ holiday_id = fields.Many2one('golem.resource.holiday', 'Holiday', required=True)
+ resource_id = fields.Many2one('golem.resource', required=True)
+ is_reservation_possible = fields.Boolean(string='Reservation during holiday')
+ period_id = fields.Many2one(related='holiday_id.period_id', store=True)
diff --git a/golem_resource_holiday/models/golem_resource_reservation.py b/golem_resource_holiday/models/golem_resource_reservation.py
new file mode 100644
index 0000000..ea041e7
--- /dev/null
+++ b/golem_resource_holiday/models/golem_resource_reservation.py
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Fabien Bourgeois
+# Copyright 2020 Youssef El Ouahby
+#
+# 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 Resources Reservation Adaptations """
+
+from odoo import models, fields, api, _
+from odoo.exceptions import ValidationError
+
+
+class GolemResourceReservation(models.Model):
+ """ GOLEM Resource Reservation Model """
+ _inherit = 'golem.resource.reservation'
+
+ @api.constrains('resource_id', 'date_start', 'date_stop')
+ def check_resource_holiday_date(self):
+ for reservation in self:
+ resource_holiday = reservation.resource_id.holiday_selection_ids.filtered(lambda s: not s.is_reservation_possible)
+ if resource_holiday:
+ for holiday in resource_holiday:
+ if (holiday.holiday_id.date_start < reservation.date_start < holiday.holiday_id.date_end) or \
+ (holiday.holiday_id.date_start < reservation.date_stop < holiday.holiday_id.date_end):
+ raise ValidationError(_('This resource cannot be reserved during the'
+ ' period between {} and {}, as there is a holiday, please choose '
+ 'another date').format(holiday.holiday_id.date_start,
+ holiday.holiday_id.date_end
+ ))
diff --git a/golem_resource_holiday/security/ir.model.access.csv b/golem_resource_holiday/security/ir.model.access.csv
new file mode 100644
index 0000000..527bca9
--- /dev/null
+++ b/golem_resource_holiday/security/ir.model.access.csv
@@ -0,0 +1,7 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_golem_resource_holiday_user,Access GOLEM Resource Holiday User,model_golem_resource_holiday,golem_base.group_golem_user,1,0,0,0
+access_golem_resource_holiday_period_user,Access GOLEM Resource Holiday Period User,model_golem_resource_holiday_period,golem_base.group_golem_user,1,0,0,0
+access_golem_resource_holiday_period_selection_user,Access GOLEM Resource Holiday Period Selection User,model_golem_resource_holiday_period_selection,golem_base.group_golem_user,1,0,0,0
+access_golem_resource_holiday_manager,Access GOLEM Resource Holiday Manager,model_golem_resource_holiday,golem_base.group_golem_manager,1,1,1,1
+access_golem_resource_holiday_period_manager,Access GOLEM Resource Holiday Period Manager,model_golem_resource_holiday_period,golem_base.group_golem_manager,1,1,1,1
+access_golem_resource_holiday_period_selection_manager,Access GOLEM Resource Holiday Period Selection Manager,model_golem_resource_holiday_period_selection,golem_base.group_golem_manager,1,1,1,1
diff --git a/golem_resource_holiday/views/golem_resource_holiday_period_views.xml b/golem_resource_holiday/views/golem_resource_holiday_period_views.xml
new file mode 100644
index 0000000..237b956
--- /dev/null
+++ b/golem_resource_holiday/views/golem_resource_holiday_period_views.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+ GOLEM Resource Holiday Period Tree
+ golem.resource.holiday.period
+
+
+
+
+
+
+
+
+
+ GOLEM Resource Holiday Period Form
+ golem.resource.holiday.period
+
+
+
+
+
+
+
+ GOLEM Resource Holiday Period search
+ golem.resource.holiday.period
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/golem_resource_holiday/views/golem_resource_holiday_views.xml b/golem_resource_holiday/views/golem_resource_holiday_views.xml
new file mode 100644
index 0000000..adc0c09
--- /dev/null
+++ b/golem_resource_holiday/views/golem_resource_holiday_views.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+ GOLEM Resource Holiday Tree
+ golem.resource.holiday
+
+
+
+
+
+
+
+
+
+
+
+
+ GOLEM Resource Holiday Form
+ golem.resource.holiday
+
+
+
+
+
+
+
+ GOLEM Resource Holiday search
+ golem.resource.holiday
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/golem_resource_holiday/views/golem_resource_views.xml b/golem_resource_holiday/views/golem_resource_views.xml
new file mode 100644
index 0000000..f88f626
--- /dev/null
+++ b/golem_resource_holiday/views/golem_resource_views.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+ GOLEM Resource Form inherit GOLEM Resource Holiday
+ golem.resource
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+