Merge branch 'fabien_resources'

This commit is contained in:
Fabien BOURGEOIS 2018-02-18 17:37:16 +01:00
commit aeefceb970
16 changed files with 889 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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, wizard

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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 non-profit resources',
'summary': 'GOLEM resources management',
'description': ''' GOLEM resources management ''',
'version': '10.0.1.6.1',
'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3',
'application': True,
'installable': True,
'depends': ['product'],
'data': ['views/golem_resource_views.xml',
'views/golem_resource_type_views.xml',
'views/golem_resource_reservation_views.xml',
'views/golem_resource_timetable_views.xml',
'wizard/golem_reservation_rejection_views.xml',
'security/ir.model.access.csv']
}

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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 golem_resource_type, \
golem_resource_timetable, \
golem_resource, \
golem_resource_reservation

View File

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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/>.
""" GOLEM Resources management """
from odoo import models, fields, api
class GolemResource(models.Model):
""" GOLEM Resource Model """
_name = 'golem.resource'
_description = 'GOLEM Resource Model'
_inherit = 'mail.thread'
_order = 'name asc'
name = fields.Char(required=True, index=True)
active = fields.Boolean(default=True)
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,
string='Linked product',
help='A generic product can be linked, in '
'order to sell reservations (work in '
'progress)')
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')
@api.multi
def active_toggle(self):
""" Toggles active boolean """
for resource in self:
resource.active = not resource.active

View File

@ -0,0 +1,199 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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/>.
""" GOLEM Resource Reservation """
from math import modf
from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
class GolemResourceReservation(models.Model):
""" GOLEM Resource Reservation Model """
_name = 'golem.resource.reservation'
_description = 'GOLEM Reservation Model'
_inherit = 'mail.thread'
_order = 'date desc,hour_start asc'
name = fields.Char(compute='_compute_name', store=True)
# TODO: handle multiple days reservation
date = fields.Date(required=True, index=True, readonly=True,
states={'draft': [('readonly', False)]})
hour_start = fields.Float('Start hour', required=True, readonly=True,
states={'draft': [('readonly', False)]})
hour_stop = fields.Float('Stop hour', required=True, readonly=True,
states={'draft': [('readonly', False)]})
date_start = fields.Datetime(compute='_compute_date_start', store=True, index=True)
date_stop = fields.Datetime(compute='_compute_date_stop', store=True, index=True)
resource_id = fields.Many2one('golem.resource', required=True, index=True,
string='Resource', readonly=True,
track_visibility='onchange',
states={'draft': [('readonly', False)]})
resource_avaibility_start = fields.Date(related='resource_id.avaibility_start')
resource_avaibility_stop = fields.Date(related='resource_id.avaibility_stop')
resource_timetable_ids = fields.One2many(related='resource_id.timetable_ids')
user_id = fields.Many2one('res.users', required=True, index=True, readonly=True,
string='User', default=lambda self: self.env.user,
states={'draft': [('readonly', False)]})
partner_id = fields.Many2one('res.partner', string='On behalf of',
required=True, index=True, readonly=True,
track_visibility='onchange',
states={'draft': [('readonly', False)]})
state = fields.Selection([('canceled', 'Canceled'),
('draft', 'Draft'),
('confirmed', 'Confirmed'),
('validated', 'Validated'),
('rejected', 'Rejected')],
default='draft', track_visibility='onchange')
rejection_reason = fields.Text(readonly=True, track_visibility='onchange')
@api.depends('resource_id', 'date')
def _compute_name(self):
""" Computes reservation name """
for reservation in self:
reservation.name = u'{}/{}'.format(reservation.resource_id.name,
reservation.date)
@api.depends('date', 'hour_start')
def _compute_date_start(self):
""" Computes Date start """
for reservation in self:
minute_start, hour_start = modf(reservation.hour_start)
hour_start = int(hour_start)
minute_start = int(round(minute_start * 60))
reservation.date_start = u'{} {}:{}:00'.format(reservation.date,
hour_start, minute_start)
@api.depends('date', 'hour_stop')
def _compute_date_stop(self):
""" Computes Date stop """
for reservation in self:
minute_stop, hour_stop = modf(reservation.hour_stop)
hour_stop = int(hour_stop)
minute_stop = int(round(minute_stop * 60))
reservation.date_stop = u'{} {}:{}:00'.format(reservation.date,
hour_stop, minute_stop)
@api.onchange('hour_start')
def onchange_hour_start(self):
""" Propose automatically stop hour after start hour had been filled """
for reservation in self:
if reservation.hour_start and not reservation.hour_stop:
reservation.hour_stop = reservation.hour_start + 1
@api.constrains('hour_start', 'hour_stop')
def _check_hour_consistency(self):
""" Checks hour consistency """
for reservation in self:
if reservation.hour_stop < reservation.hour_start:
raise ValidationError(_('End time should be after than start time'))
@api.multi
def state_draft(self):
""" Status to draft """
self.write({'state': 'draft'})
@api.multi
def state_confirm(self):
""" Confirms reservation, or validates it if not workflow is involved """
for reservation in self:
# Needed, for constraint checking
reservation.state = 'confirmed'
if not reservation.resource_id.validation_required:
reservation.state = 'validated'
@api.multi
def state_canceled(self):
""" Status to cancel """
self.write({'state': 'canceled'})
@api.multi
def state_validated(self):
""" Status to validated """
self.write({'state': 'validated'})
@api.multi
def state_rejected(self):
""" Wizard call for reservation reject """
self.ensure_one()
reservation_id = self[0]
return {'name' : _('Please enter the rejection reason'),
'type' : 'ir.actions.act_window',
'res_model' : 'golem.reservation.rejection.wizard',
'context': {'default_reservation_id': reservation_id.id},
'view_mode': 'form',
'target': 'new'}
@api.constrains('state')
def check_access(self):
""" Checks access when state is updated """
reservation = self[0]
if reservation.state in ('rejected', 'validated'):
if not self.env.user.has_group('golem_base.group_golem_manager'):
uerr = _('You do not have permissions to validate or reject a reservation.')
raise UserError(uerr)
@api.constrains('state')
def check_confirmed(self):
""" Check date coherence on reservation confirmation """
for reservation in self:
if reservation.state == 'confirmed':
# Check is reservation is not taking place out of the resource avaibility period
if reservation.date < reservation.resource_id.avaibility_start or \
reservation.date > reservation.resource_id.avaibility_stop:
uerr = _('Not allowed, the resource is not available in '
'this period, please choose another périod before '
'confirming')
raise UserError(uerr)
# Check if reservation is not taking place out the avaibility timetables
is_day_allowed = False
for timetable in reservation.resource_id.timetable_ids:
# Check for the time according to resource timetable avaibility
date = fields.Datetime.from_string(reservation.date)
if int(timetable.weekday) == date.weekday():
is_day_allowed = True
if reservation.hour_start < timetable.time_start or \
reservation.hour_stop > timetable.time_stop:
uerr = _('Not allowed, the resource is not available '
'during this period, please choose another '
'time before confirming.')
raise UserError(uerr)
if not is_day_allowed:
uerr = _('Not allowed, the resource is not available '
'this day. Please choose another date.')
raise UserError(uerr)
# Check if the resource is already taken during this period
# PERF : check the date, not iterate over all reservations
domain = [('resource_id', '=', reservation.resource_id.id),
('date', '=', reservation.date),
('state', 'in', ('confirmed', 'validated')),
('id', '!=', reservation.id)]
reservations = self.env['golem.resource.reservation'].search(domain)
for other_res in reservations:
if (other_res.hour_start < reservation.hour_start < other_res.hour_stop) or \
(other_res.hour_start < reservation.hour_stop < other_res.hour_stop):
uerr = _('Not allowed, the resource is already taken '
'during this period : from {} to {} this day, '
'please choose another périod before confirming.')
raise UserError(uerr.format(other_res.date_start,
other_res.date_stop))

View File

@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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/>.
""" GOLEM Resource Timetable """
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class GolemTimetable(models.Model):
""" Golem Timetable """
_name = "golem.resource.timetable"
_description = "Golem Timetable"
_rec_name = 'weekday'
_order = 'weekday asc,time_start asc'
resource_id = fields.Many2one('golem.resource', required=True,
string='Linked resource')
weekday = fields.Selection([('0', _('Monday')),
('1', _('Tuesday')),
('2', _('Wednesday')),
('3', _('Thursday')),
('4', _('Friday')),
('5', _('Saturday')),
('6', _('Sunday'))], required=True)
time_start = fields.Float(required=True, string='Start')
time_stop = fields.Float(required=True, string='Stop')
@api.onchange('time_start')
def onchange_time_start(self):
""" Propose automatically stop hour after start hour had been filled """
for line in self:
if line.time_start and not line.time_stop:
line.time_stop = line.time_start + 1
@api.constrains('time_start', 'time_stop')
def _check_time_consistency(self):
""" Checks time consistency """
for timetable in self:
if timetable.time_stop < timetable.time_start:
raise ValidationError(_('End time should be after than start time'))

View File

@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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/>.
""" GOLEM Resource Type """
from odoo import models, fields
class GolemResourceType(models.Model):
""" GOLEM Resource Type """
_name = 'golem.resource.type'
_description = 'GOLEM Resource Type'
_order = 'name asc'
_sql_constraints = [('golem_resource_type_name_uniq',
'UNIQUE (name)',
'Resource type must be unique.')]
name = fields.Char(string='Resource Type', required=True, index=True)

View File

@ -0,0 +1,9 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_golem_resource_user,Access GOLEM Resource User,model_golem_resource,golem_base.group_golem_user,1,0,0,0
access_golem_resource_manager,Access GOLEM Resource Manager,model_golem_resource,golem_base.group_golem_manager,1,1,1,1
access_golem_resource_type_user,Access GOLEM Resource Type User,model_golem_resource_type,golem_base.group_golem_user,1,0,0,0
access_golem_resource_type_manager,Access GOLEM Resource Type Manager,model_golem_resource_type,golem_base.group_golem_manager,1,1,1,1
access_golem_resource_reservation_user,Access GOLEM Resource Reservation User,model_golem_resource_reservation,golem_base.group_golem_user,1,1,1,0
access_golem_resource_reservation_manager,Access GOLEM Resource Reservation Manager,model_golem_resource_reservation,golem_base.group_golem_manager,1,1,1,1
access_golem_resource_timetable_user,Access GOLEM Resource Timetable User,model_golem_resource_timetable,golem_base.group_golem_user,1,0,0,0
access_golem_resource_timetable_manager,Access GOLEM Resource Timetable Manager,model_golem_resource_timetable,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_user Access GOLEM Resource User model_golem_resource golem_base.group_golem_user 1 0 0 0
3 access_golem_resource_manager Access GOLEM Resource Manager model_golem_resource golem_base.group_golem_manager 1 1 1 1
4 access_golem_resource_type_user Access GOLEM Resource Type User model_golem_resource_type golem_base.group_golem_user 1 0 0 0
5 access_golem_resource_type_manager Access GOLEM Resource Type Manager model_golem_resource_type golem_base.group_golem_manager 1 1 1 1
6 access_golem_resource_reservation_user Access GOLEM Resource Reservation User model_golem_resource_reservation golem_base.group_golem_user 1 1 1 0
7 access_golem_resource_reservation_manager Access GOLEM Resource Reservation Manager model_golem_resource_reservation golem_base.group_golem_manager 1 1 1 1
8 access_golem_resource_timetable_user Access GOLEM Resource Timetable User model_golem_resource_timetable golem_base.group_golem_user 1 0 0 0
9 access_golem_resource_timetable_manager Access GOLEM Resource Timetable Manager model_golem_resource_timetable golem_base.group_golem_manager 1 1 1 1

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 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/>.
-->
<odoo>
<data>
<!-- Calendars -->
<record model="ir.ui.view" id="golem_resource_reservation_view_calendar">
<field name="name">GOLEM Resource Reservation Calendar</field>
<field name="model">golem.resource.reservation</field>
<field name="arch" type="xml">
<calendar date_start="date_start" date_stop="date_stop" color="resource_id">
<field name="resource_id" />
<field name="user_id" />
<field name="partner_id" />
</calendar>
</field>
</record>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_reservation_view_tree">
<field name="name">GOLEM Resource Reservation Tree</field>
<field name="model">golem.resource.reservation</field>
<field name="arch" type="xml">
<tree>
<field name="resource_id" />
<field name="date" />
<field name="hour_start" widget="float_time" />
<field name="hour_stop" widget="float_time" />
<field name="partner_id" />
<field name="state" />
</tree>
</field>
</record>
<!-- Forms -->
<record model="ir.ui.view" id="golem_resource_reservation_view_form">
<field name="name">GOLEM Resource Reservation Form</field>
<field name="model">golem.resource.reservation</field>
<field name="arch" type="xml">
<form>
<header>
<button name="state_confirm" type="object" string="Confirm" class="oe_highlight"
attrs="{'invisible': ['|', ('state', 'not in', 'draft'), ('id', '=', False)]}" />
<button name="state_canceled" type="object"
string="Cancel" states="confirmed,validated" />
<button name="state_draft" type="object" string="Set to draft"
states="canceled,confirmed,validated,rejected" />
<button name="state_validated" type="object" string="Validate"
states="confirmed" class="oe_highlight"
groups="golem_base.group_golem_manager" />
<button name="state_rejected" type="object" string="Reject"
states="confirmed" class="oe_highlight"
groups="golem_base.group_golem_manager" />
<field name="state" widget="statusbar" />
</header>
<sheet>
<group>
<group string="Resource">
<field name="id" invisible="1" />
<field name="resource_id" options="{'no_create': True}" />
<field name="resource_avaibility_start" readonly="1" />
<field name="resource_avaibility_stop" readonly="1" />
<field name="resource_timetable_ids" readonly="1" />
</group>
<group string="Reservation">
<group>
<field name="date" />
<field name="hour_start" widget="float_time" />
<field name="hour_stop" widget="float_time" />
<field name="user_id" options="{'no_create': True}" />
<field name="partner_id" />
<field name="rejection_reason"
attrs="{'invisible': [('state', '!=', 'rejected')]}"/>
</group>
</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_reservation_view_search">
<field name="name">GOLEM Resource Reservation Search</field>
<field name="model">golem.resource.reservation</field>
<field name="arch" type="xml">
<search>
<field name="date_start" />
<field name="date_stop" />
<field name="resource_id" />
<field name="user_id" />
<field name="partner_id" />
<field name="state" />
<filter name="to_validate" string="Reservation to Validate"
domain="[('state', '=', 'confirmed')]" />
<filter name="group_state" string="State"
context="{'group_by': 'state'}" />
<filter name="group_resource" string="Resource"
context="{'group_by': 'resource_id'}" />
<filter name="group_partner_id" string="Partner"
context="{'group_by': 'partner_id'}" />
<filter name="group_user" string="User"
context="{'group_by': 'user_id'}" />
<filter name="group_date_month" string="Month"
context="{'group_by': 'date:month'}" />
<filter name="group_date_week" string="Week"
context="{'group_by': 'date:week'}" />
<filter name="group_date_day" string="Day"
context="{'group_by': 'date:day'}" />
</search>
</field>
</record>
<!-- Actions -->
<act_window id="golem_resource_reservation_action" name="Reservations"
res_model="golem.resource.reservation" view_mode="tree,form,calendar" />
<!-- Menus -->
<menuitem id="golem_resource_reservation_menu" name="Reservations"
parent="golem_resource_menu" action="golem_resource_reservation_action"
sequence="20" />
</data>
</odoo>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 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/>.
-->
<odoo>
<data>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_timetable_view_tree">
<field name="name">GOLEM Resource Timetable Tree</field>
<field name="model">golem.resource.timetable</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="resource_id" invisible="1" />
<field name="weekday" />
<field name="time_start" string="Start hour" widget="float_time" />
<field name="time_stop" string="Stop hour" widget="float_time" />
</tree>
</field>
</record>
</data>
</odoo>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 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/>.
-->
<odoo>
<data>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_type_view_tree">
<field name="name">GOLEM Resource Type Tree</field>
<field name="model">golem.resource.type</field>
<field name="arch" type="xml">
<tree editable="bottom">
<field name="name" />
</tree>
</field>
</record>
<!-- Searches -->
<record model="ir.ui.view" id="golem_resource_type_view_search">
<field name="name">GOLEM Resource Type Search</field>
<field name="model">golem.resource.type</field>
<field name="arch" type="xml">
<search>
<field name="name" />
</search>
</field>
</record>
<!-- Actions -->
<act_window id="golem_resource_type_action" name="Resource Types"
res_model="golem.resource.type" view_mode="tree" />
<!-- Menus -->
<menuitem id="resource_cofiguration_type_menu" name="Resource Types"
parent="resource_configuration_menu"
action="golem_resource_type_action" sequence="10" />
</data>
</odoo>

View File

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 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/>.
-->
<odoo>
<data>
<!-- Trees -->
<record model="ir.ui.view" id="golem_resource_view_tree">
<field name="name">GOLEM Resource Tree</field>
<field name="model">golem.resource</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="type_id" />
<field name="supervisor_id" />
<field name="product_tmpl_id" />
<field name="avaibility_start" />
<field name="avaibility_stop" />
<field name="validation_required" />
</tree>
</field>
</record>
<!-- Forms -->
<record model="ir.ui.view" id="golem_resource_view_form">
<field name="name">GOLEM Resource Form</field>
<field name="model">golem.resource</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_button_box" name="button_box">
<button class="oe_stat_button" icon="fa-archive"
name="active_toggle" type="object">
<field name="active" widget="boolean_button"
options="{'terminology': 'archive'}" />
</button>
</div>
<group>
<group>
<field name="name" />
<field name="type_id" />
<field name="product_tmpl_id" options="{'no_create': True}" />
</group>
<group>
<field name="validation_required" />
<field name="supervisor_id" />
</group>
</group>
<group string="Availibility configuration">
<group colspan="2">
<field name="id" invisible="1"/>
<field name="avaibility_start" />
<field name="avaibility_stop" />
</group>
<p attrs="{'invisible': [('id', '!=', False)]}">
Please save the resource before fixing the timetable availibility"
</p>
<group colspan="2">
<field name="timetable_ids"
context="{'default_resource_id': active_id}"
attrs="{'readonly': [('id', '=', False)]}" />
</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_view_search">
<field name="name">GOLEM Resource search</field>
<field name="model">golem.resource</field>
<field name="arch" type="xml">
<search>
<field name="name" />
<field name="type_id" />
<field name="supervisor_id" />
<field name="product_tmpl_id" />
<filter name="with_validation" string="With validation"
domain="[('validation_required', '=', True)]" />
<filter name="without_validation" string="Without validation"
domain="[('validation_required', '=', False)]" />
<separator />
<filter name="archived" string="Archived"
domain="[('active', '=', False)]" />
<filter name="group_type" string="Type"
context="{'group_by': 'type_id'}"/>
<filter name="group_supervisor" string="Supervisor"
context="{'group_by': 'supervisor_id'}"/>
<filter name="group_product" string="Linked product"
context="{'group_by': 'product_tmpl_id'}"/>
</search>
</field>
</record>
<!-- Actions -->
<act_window id="golem_resource_action" name="Resources"
res_model="golem.resource" view_mode="tree,form" />
<!-- Menus -->
<menuitem id="golem_resource_menu" name="Resources"
sequence="55" groups="golem_base.group_golem_user"
web_icon="golem_resource,static/description/icon.png" />
<menuitem id="resource_list_menu" name="Resources" parent="golem_resource_menu"
action="golem_resource_action" sequence="10" />
<menuitem id="resource_configuration_menu" name="Configuration"
parent="golem_resource_menu" groups="golem_base.group_golem_manager"
sequence="90" />
</data>
</odoo>

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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 golem_reservation_rejection

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
# Copyright 2018 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/>.
""" GOLEM Resources management """
from odoo import models, fields, api
class GolemReservationRejectionWizard(models.TransientModel):
"""GOLEM Resource wizard : refusal reason for a reservation """
_name = "golem.reservation.rejection.wizard"
reservation_id = fields.Many2one('golem.resource.reservation', required=True)
reason = fields.Text(required=True)
@api.multi
def reject(self):
""" Sets reservation status to rejected and add reason """
self.ensure_one()
rejection = self[0]
rejection.reservation_id.write({'state': 'rejected',
'rejection_reason': rejection.reason})

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 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/>.
-->
<odoo>
<data>
<!-- Forms -->
<record model="ir.ui.view" id="golem_reservation_rejection_wizard_view_form">
<field name="name">GOLEM Reservation Rejection Wizard Form</field>
<field name="model">golem.reservation.rejection.wizard</field>
<field name="arch" type="xml">
<form string="Rejection reason">
<group>
<field name="reservation_id" readonly="1" />
<field name="reason" />
</group>
<footer>
<button name="reject" string="Reject" type="object"
class="oe_highlight" />
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</data>
</odoo>