From 517d7432576985c5969abc04c8935e9eef649055 Mon Sep 17 00:00:00 2001 From: Youssef ELOUAHBY Date: Thu, 21 May 2020 23:32:49 +0000 Subject: [PATCH] create module golem_resource_holiday --- golem_resource_holiday/__init__.py | 19 ++++ golem_resource_holiday/__manifest__.py | 38 ++++++++ golem_resource_holiday/models/__init__.py | 21 +++++ .../models/golem_resource.py | 28 ++++++ .../models/golem_resource_holiday.py | 52 +++++++++++ .../models/golem_resource_holiday_period.py | 33 +++++++ ...golem_resource_holiday_period_selection.py | 32 +++++++ .../security/ir.model.access.csv | 7 ++ .../golem_resource_holiday_period_views.xml | 79 ++++++++++++++++ .../views/golem_resource_holiday_views.xml | 89 +++++++++++++++++++ .../views/golem_resource_views.xml | 44 +++++++++ 11 files changed, 442 insertions(+) create mode 100644 golem_resource_holiday/__init__.py create mode 100644 golem_resource_holiday/__manifest__.py create mode 100644 golem_resource_holiday/models/__init__.py create mode 100644 golem_resource_holiday/models/golem_resource.py create mode 100644 golem_resource_holiday/models/golem_resource_holiday.py create mode 100644 golem_resource_holiday/models/golem_resource_holiday_period.py create mode 100644 golem_resource_holiday/models/golem_resource_holiday_period_selection.py create mode 100644 golem_resource_holiday/security/ir.model.access.csv create mode 100644 golem_resource_holiday/views/golem_resource_holiday_period_views.xml create mode 100644 golem_resource_holiday/views/golem_resource_holiday_views.xml create mode 100644 golem_resource_holiday/views/golem_resource_views.xml 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..be75a73 --- /dev/null +++ b/golem_resource_holiday/models/__init__.py @@ -0,0 +1,21 @@ +# -*- 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_period_selection) diff --git a/golem_resource_holiday/models/golem_resource.py b/golem_resource_holiday/models/golem_resource.py new file mode 100644 index 0000000..cf9f619 --- /dev/null +++ b/golem_resource_holiday/models/golem_resource.py @@ -0,0 +1,28 @@ +# -*- 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 + + +class GolemResource(models.Model): + """ GOLEM Resource Model """ + _inherit = 'golem.resource' + + holiday_period_selection = fields.One2many('golem.resource.holiday.period.selection', '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..48b7829 --- /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') + def _compute_name(self): + """ Computes holiday name """ + for holiday in self: + holiday.name = u'{}/{}/{}'.format(holiday.period_id.name, + holiday.date_start, + holiday.id) + + @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_period_selection.py b/golem_resource_holiday/models/golem_resource_holiday_period_selection.py new file mode 100644 index 0000000..9b2d40a --- /dev/null +++ b/golem_resource_holiday/models/golem_resource_holiday_period_selection.py @@ -0,0 +1,32 @@ +# -*- 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 Selection Management """ + +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError + + +class GolemResourceHolidayPeriodSelection(models.Model): + """ GOLEM Resource Holiday Period Selection""" + _name = 'golem.resource.holiday.period.selection' + _description = 'GOLEM Resource Holiday Period Selection Managementl' + + holiday_period_id = fields.Many2one('golem.resource.holiday.period', required=True) + resource_id = fields.Many2one('golem.resource', required=True) + is_reservation_possible = fields.Boolean() 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..7403e71 --- /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..a426014 --- /dev/null +++ b/golem_resource_holiday/views/golem_resource_views.xml @@ -0,0 +1,44 @@ + + + + + + + GOLEM Resource Form inherit GOLEM Resource Holiday + golem.resource + + + + + + + + + + + + + + + + + + +