create module golem_resource_holiday

This commit is contained in:
Youssef Elouahby 2020-05-21 23:32:49 +00:00
parent 300676c204
commit 517d743257
11 changed files with 442 additions and 0 deletions

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,21 @@
# -*- 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_period_selection)

View File

@ -0,0 +1,28 @@
# -*- 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
class GolemResource(models.Model):
""" GOLEM Resource Model """
_inherit = 'golem.resource'
holiday_period_selection = fields.One2many('golem.resource.holiday.period.selection', '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')
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'))

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,32 @@
# -*- 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 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()

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"/>
</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.golem_resource_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,44 @@
<?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_selection" context="{'default_resource_id': active_id}">
<tree editable="top">
<field name="resource_id" invisible="1"/>
<field name="holiday_period_id"/>
<field name="is_reservation_possible"/>
</tree>
</field>
</group>
</page>
</page>
</field>
</record>
</data>
</odoo>