Ressources : gestion des vacances / congés #48

Open
youssef wants to merge 3 commits from youssef/GOLEM:ressources_gestion_vacances_conges into master
13 changed files with 539 additions and 18 deletions

View File

@ -68,24 +68,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="supervisor_id" />
</group>
</group>
<group string="availability configuration">
<group colspan="2">
<field name="id" invisible="1"/>
<field name="availability_24_7"/>
<field name="availability_start" />
<field name="availability_stop" />
</group>
<p attrs="{'invisible': ['|',
('id', '!=', False),
('availability_24_7', '=', True)]}">
Please save the resource before fixing the timetable availability"
</p>
<group colspan="2" attrs="{'invisible': [('availability_24_7', '=', True)]}">
<field name="timetable_ids"
context="{'default_resource_id': active_id}"
attrs="{'readonly': [('id', '=', False)]}" />
</group>
</group>
<notebook>
<page name="availability" string="availability configuration">
<group>
<group colspan="2">
<field name="id" invisible="1"/>
<field name="availability_24_7"/>
<field name="availability_start" />
<field name="availability_stop" />
</group>
<p attrs="{'invisible': ['|',
('id', '!=', False),
('availability_24_7', '=', True)]}">
Please save the resource before fixing the timetable availability"
</p>
<group colspan="2" attrs="{'invisible': [('availability_24_7', '=', True)]}">
<field name="timetable_ids"
context="{'default_resource_id': active_id}"
attrs="{'readonly': [('id', '=', False)]}" />
</group>
</group>
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
#
# 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/>.
from . import models

View File

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
#
# 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/>.
{
'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'
]
}

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
from . import ( golem_resource_holiday, golem_resource_holiday_period,
golem_resource, golem_resource_holiday_selection,
golem_resource_reservation)

View File

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
""" 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,
})

View File

@ -0,0 +1,52 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
""" 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'))

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
""" 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)

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
""" 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)

View File

@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
#
# 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/>.
""" 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
))

View File

@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_golem_resource_holiday_user Access GOLEM Resource Holiday User model_golem_resource_holiday golem_base.group_golem_user 1 0 0 0
3 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
4 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
5 access_golem_resource_holiday_manager Access GOLEM Resource Holiday Manager model_golem_resource_holiday golem_base.group_golem_manager 1 1 1 1
6 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
7 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

View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
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/>.
-->
<odoo>
<data>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_holiday_period_view_tree">
<field name="name">GOLEM Resource Holiday Period Tree</field>
<field name="model">golem.resource.holiday.period</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
</tree>
</field>
</record>
<!-- Forms -->
<record model="ir.ui.view" id="golem_resource_holiday_period_view_form">
<field name="name">GOLEM Resource Holiday Period Form</field>
<field name="model">golem.resource.holiday.period</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="name"/>
</group>
<group>
<field name="active"/>
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
</form>
</field>
</record>
<!-- Searches -->
<record model="ir.ui.view" id="golem_resource_holiday_period_view_search">
<field name="name">GOLEM Resource Holiday Period search</field>
<field name="model">golem.resource.holiday.period</field>
<field name="arch" type="xml">
<search>
<field name="name" />
</search>
</field>
</record>
<!-- Actions -->
<act_window id="golem_resource_holiday_period_action" name="Resource Holiday Period"
res_model="golem.resource.holiday.period" view_mode="tree,form" />
<!-- Menus -->
<menuitem id="resource_holiday_period_menu" name="Period"
parent="resource_holiday_root_menu"
action="golem_resource_holiday_period_action"
sequence="20" />
</data>
</odoo>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
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/>.
-->
<odoo>
<data>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_holiday_view_tree">
<field name="name">GOLEM Resource Holiday Tree</field>
<field name="model">golem.resource.holiday</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="period_id"/>
<field name="date_start"/>
<field name="date_end"/>
</tree>
</field>
</record>
<!-- Forms -->
<record model="ir.ui.view" id="golem_resource_holiday_view_form">
<field name="name">GOLEM Resource Holiday Form</field>
<field name="model">golem.resource.holiday</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="period_id" options="{'no_create': True}"/>
</group>
<group>
<field name="date_start"/>
<field name="date_end"/>
</group>
</group>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
</form>
</field>
</record>
<!-- Searches -->
<record model="ir.ui.view" id="golem_resource_holiday_view_search">
<field name="name">GOLEM Resource Holiday search</field>
<field name="model">golem.resource.holiday</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<field name="period_id" />
<filter name="group_period" string="Period"
context="{'group_by': 'period_id'}"/>
</search>
</field>
</record>
<!-- Actions -->
<act_window id="golem_resource_holiday_action" name="Resource Holiday"
res_model="golem.resource.holiday" view_mode="tree,form" />
<!-- Menus -->
<menuitem id="resource_holiday_root_menu" name="Resources Holiday"
parent="golem_resource.resource_configuration_menu"
sequence="50"/>
<menuitem id="resource_holiday_menu" name="Holiday"
parent="resource_holiday_root_menu"
action="golem_resource_holiday_action"
sequence="10"/>
</data>
</odoo>

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2020 Fabien Bourgeois <fabien@yaltik.com>
Copyright 2020 Youssef El Ouahby <youssef@yaltik.com>
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/>.
-->
<odoo>
<data>
<!-- Forms -->
<record model="ir.ui.view"
id="golem_resource_view_form_inherit_golem_resource_holiday">
<field name="name"> GOLEM Resource Form inherit GOLEM Resource Holiday</field>
<field name="model">golem.resource</field>
<field name='inherit_id' ref="golem_resource.golem_resource_view_form"/>
<field name="arch" type="xml">
<page name="availability" position="after">
<page name="holiday_period_selection" string="Holiday Period Selection">
<group>
<field name="holiday_period_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="holiday_selection_ids"
context="{'default_resource_id': active_id}"
attrs="{'invisible': [('holiday_period_ids', '=', [])]}">
<tree create="false" edit="true" delete="false" editable="top">
<field name="resource_id" invisible="1"/>
<field name="holiday_id" readonly="1"/>
<field name="is_reservation_possible"/>
</tree>
</field>
</group>
</page>
</page>
</field>
</record>
</data>
</odoo>