Merge branch 'reservations_report'

This commit is contained in:
Fabien BOURGEOIS 2018-05-25 16:58:47 +02:00
commit 3353db163f
13 changed files with 779 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 reports, wizard

View File

@ -0,0 +1,35 @@
# -*- 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 resources reports',
'summary': 'GOLEM resources reports',
'description': ''' GOLEM resources reports ''',
'version': '10.0.0.1.0',
'category': 'GOLEM',
'author': 'Youssef El Ouahby, Fabien Bourgeois',
'license': 'AGPL-3',
'application': False,
'installable': True,
'depends': ['golem_resource'],
'data': ['data/golem_resource_report_data.xml',
'reports/golem_reservation_report.xml',
'reports/golem_reservation_report_menu.xml',
'wizard/golem_resource_report_wizard_views.xml',
'views/golem_resource_report_menu.xml']
}

View File

@ -0,0 +1,40 @@
<?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>
<record id="paperformat_euro_landscape"
model="report.paperformat">
<field name="name">European A4 Landscape</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Landscape</field>
<field name="margin_top">10</field>
<field name="margin_bottom">23</field>
<field name="margin_left">7</field>
<field name="margin_right">7</field>
<field name="header_line" eval="False" />
<field name="header_spacing">35</field>
<field name="dpi">90</field>
</record>
</data>
</odoo>

View File

@ -0,0 +1,147 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_resource_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-25 14:50+0000\n"
"PO-Revision-Date: 2018-05-25 14:50+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<br/>\n"
" To"
msgstr "<br/>\n"
" À"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<strong>From Date: </strong>"
msgstr "<strong>De : </strong>"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<strong>To Date:</strong>"
msgstr "<strong>À :</strong>"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Close"
msgstr "Fermer"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_uid
msgid "Created by"
msgstr "Créé par"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_date
msgid "Created on"
msgstr "Créé le"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_start
msgid "Date start"
msgstr "Date de début"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_stop
msgid "Date stop"
msgstr "Date de fin"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_display_name
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "For"
msgstr "Pour"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "From"
msgstr "De"
#. module: golem_resource_report
#: model:ir.model,name:golem_resource_report.model_report_golem_resource_report_golem_reservation_report
msgid "Golem Reservation Report"
msgstr "Golem Reservation Report"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_id
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_id
msgid "ID"
msgstr "ID"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard___last_update
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report___last_update
msgid "Last Modified on"
msgstr "Dernière Modification le"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Print Report"
msgstr "Imprimer le rapport"
#. module: golem_resource_report
#: model:ir.ui.menu,name:golem_resource_report.resource_report_menu
msgid "Report"
msgstr "Rapport"
#. module: golem_resource_report
#: model:ir.actions.report.xml,name:golem_resource_report.action_report_report_admission_analysis
msgid "Reservations Report"
msgstr "Export réservations"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Resource Report"
msgstr "Ressource"
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_resource_ids
msgid "Resource ids"
msgstr "Resources"
#. module: golem_resource_report
#: model:ir.actions.act_window,name:golem_resource_report.golem_resource_report_action
msgid "Resources Reports"
msgstr "Ressources"
#. module: golem_resource_report
#: code:addons/golem_resource_report/wizard/golem_resource_report_wizard.py:38
#, python-format
msgid "Stop Date cannot be set before Start Date."
msgstr "La date de fin ne peut pas être antérieure à celle de début."
#. module: golem_resource_report
#: model:ir.model,name:golem_resource_report.model_golem_resource_report_wizard
msgid "golem.resource.report.wizard"
msgstr "golem.resource.report.wizard"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "reservations<br/>"
msgstr "réservations<br/>"

View File

@ -0,0 +1,147 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_resource_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-25 14:50+0000\n"
"PO-Revision-Date: 2018-05-25 14:50+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<br/>\n"
" To"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<strong>From Date: </strong>"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "<strong>To Date:</strong>"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Close"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_uid
msgid "Created by"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_create_date
msgid "Created on"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_start
msgid "Date start"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_date_stop
msgid "Date stop"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_display_name
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_display_name
msgid "Display Name"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "For"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "From"
msgstr ""
#. module: golem_resource_report
#: model:ir.model,name:golem_resource_report.model_report_golem_resource_report_golem_reservation_report
msgid "Golem Reservation Report"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_id
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report_id
msgid "ID"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard___last_update
#: model:ir.model.fields,field_description:golem_resource_report.field_report_golem_resource_report_golem_reservation_report___last_update
msgid "Last Modified on"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_uid
msgid "Last Updated by"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_write_date
msgid "Last Updated on"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Print Report"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.menu,name:golem_resource_report.resource_report_menu
msgid "Report"
msgstr ""
#. module: golem_resource_report
#: model:ir.actions.report.xml,name:golem_resource_report.action_report_report_admission_analysis
msgid "Reservations Report"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_resource_report_wizard_view_form
msgid "Resource Report"
msgstr ""
#. module: golem_resource_report
#: model:ir.model.fields,field_description:golem_resource_report.field_golem_resource_report_wizard_resource_ids
msgid "Resource ids"
msgstr ""
#. module: golem_resource_report
#: model:ir.actions.act_window,name:golem_resource_report.golem_resource_report_action
msgid "Resources Reports"
msgstr ""
#. module: golem_resource_report
#: code:addons/golem_resource_report/wizard/golem_resource_report_wizard.py:38
#, python-format
msgid "Stop Date cannot be set before Start Date."
msgstr ""
#. module: golem_resource_report
#: model:ir.model,name:golem_resource_report.model_golem_resource_report_wizard
msgid "golem.resource.report.wizard"
msgstr ""
#. module: golem_resource_report
#: model:ir.ui.view,arch_db:golem_resource_report.golem_reservation_report
msgid "reservations<br/>"
msgstr ""

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_report

View File

@ -0,0 +1,108 @@
# -*- 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 Reservation Report """
import time
from random import randint
from odoo import models, fields, api
# FIXME: usage of Odoo fields will be needed for i18n awareness
def get_client_color(partner_number):
""" Get Client Color """
colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750',
'#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652']
color = "#000000"
if partner_number < 10:
color = colors[partner_number]
else:
red = randint(128, 255)
green = randint(128, 255)
blue = randint(128, 255)
color = "#" +hex(red)[2:]+hex(green)[2:]+hex(blue)[2:]
return color
class GolemResevationReport(models.AbstractModel):
""" Golem Reservation Report """
_name = 'report.golem_resource_report.golem_reservation_report'
_description = 'Golem Reservation Report'
def get_data(self, data):
""" Get Resevation Data """
domain = [('state', '=', 'validated'),
('date_start', '>', data['date_start']),
('date_stop', '<', data['date_stop']),
('resource_id', 'in', data['resource_ids'])]
reservations = self.env['golem.resource.reservation'].search(domain, order='date_start')
total_reservations = len(reservations)
resources = {r.resource_id.id: r.resource_id.name for r in reservations}
days = sorted(list(set(reservations.mapped('day_start'))))
partner_ids = reservations.mapped('partner_id.id')
partner_colors = {}
partner_number = 0
for partner_id in partner_ids:
partner_colors[str(partner_id)] = get_client_color(partner_number)
partner_number += 1
res = {} # List of multi-levels : group by resource, then, day_start
for reservation in reservations:
resource = reservation.resource_id.id
day_start = reservation.day_start
if not resource in res:
res[resource] = {}
if not day_start in res[resource]:
res[resource][day_start] = []
line = {
'name': reservation.name,
'resource_name': reservation.resource_id.name,
'partner': reservation.partner_id.name,
'date_start': reservation.date_start,
'date_stop': reservation.date_stop,
'day_start': reservation.day_start,
'day_stop': fields.Datetime.from_string(reservation.date_stop).strftime('%Y-%m-%d'),
'bgcolor': partner_colors[str(reservation.partner_id.id)],
'note': reservation.note
}
res[resource][day_start].append(line)
return res, total_reservations, resources, days
@api.model
def render_html(self, docids, data=None):
""" Render HTML """
model = self.env.context.get('active_model')
docs = self.env[model].browse(self.env.context.get('active_id'))
_data, total_reservations, resources, days = self.get_data(data)
docargs = {
'doc_ids': self.ids,
'doc_model': model,
'docs': docs,
'company': self.env.ref('base.main_company'),
'time': time,
'data': data,
'date_start': '%s 00:00:00' % data['date_start'],
'date_stop': '%s 23:59:59' % data['date_stop'],
'total_reservations': total_reservations,
'datas': _data,
'resources': resources,
'days': days
}
return self.env['report'] \
.render('golem_resource_report.golem_reservation_report', docargs)

View File

@ -0,0 +1,80 @@
<?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>
<template id="golem_reservation_report">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="font">
<div class="page">
<h3 class="text-center">
<span t-esc="company.name" /> : <span t-esc="total_reservations" /> reservations<br />
<small>
<strong>From Date: </strong>
<span t-esc="time.strftime('%d/%m/%Y',time.strptime(date_start,'%Y-%m-%d %H:%M:%S'))"/>
<strong>To Date:</strong>
<span t-esc="time.strftime('%d/%m/%Y',time.strptime(date_stop,'%Y-%m-%d %H:%M:%S'))"/>
</small>
</h3>
<table class="table table-striped">
<thead>
<tr>
<th></th>
<t t-foreach="days" t-as="day">
<th class="text-center" t-esc="time.strftime('%A %d/%m',time.strptime(day,'%Y-%m-%d'))"/>
</t>
</tr>
</thead>
<tbody>
<tr t-foreach="resources" t-as="resource_id">
<td><span t-esc="resources[resource_id]" /></td>
<t t-foreach="days" t-as="day">
<td>
<t t-if="datas.get(resource_id, {}).get(day)">
<t t-set="reservations" t-value="datas[resource_id][day]" />
<t t-foreach="reservations" t-as="resa">
<div t-attf-style="background-color:{{resa['bgcolor']}}!important;border-top: 1px solid #333333;">
<t t-if="resa['day_start']==resa['day_stop']">
<span t-esc="time.strftime('%Hh%M',time.strptime(resa['date_start'],'%Y-%m-%d %H:%M:%S'))"/> -
<span t-esc="time.strftime('%Hh%M',time.strptime(resa['date_stop'],'%Y-%m-%d %H:%M:%S'))"/>
</t>
<t t-else="">
From <span t-esc="time.strftime('%d/%m %Hh%M',time.strptime(resa['date_start'],'%Y-%m-%d %H:%M:%S'))"/><br />
To <span t-esc="time.strftime('%d/%m %Hh%M',time.strptime(resa['date_stop'],'%Y-%m-%d %H:%M:%S'))"/>
</t>
<p t-if="resa.get('note')" t-esc="resa['note']" />
<br />
<em>For <span t-esc="resa['partner']"/></em>
</div>
</t>
</t>
</td>
</t>
</tr>
</tbody>
</table>
</div>
</div>
</t>
</t>
</template>
</data>
</odoo>

View File

@ -0,0 +1,32 @@
<?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>
<report id="action_report_report_admission_analysis"
model="golem.resource.report.wizard"
string="Reservations Report"
report_type="qweb-pdf"
name="golem_resource_report.golem_reservation_report"
file="golem_resource_report.golem_reservation_report"
menu="False" auto="False"
paperformat="paperformat_euro_landscape" />
</data>
</odoo>

View File

@ -0,0 +1,38 @@
<?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>
<!-- Actions -->
<record model="ir.actions.act_window" id="golem_resource_report_action">
<field name="name">Resources Reports</field>
<field name="res_model">golem.resource.report.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="golem_resource_report_wizard_view_form" />
<field name="context">{}</field>
<field name="target">new</field>
</record>
<!-- Menus -->
<menuitem id="resource_report_menu" name="Report" parent="golem_resource.golem_resource_menu"
action="golem_resource_report_action" sequence="10" />
</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_resource_report_wizard

View File

@ -0,0 +1,44 @@
# -*- 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 Report Wizard """
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class GolemResourceReportWizard(models.TransientModel):
"""GOLEM Report Wizard : Choose report parameters """
_name = "golem.resource.report.wizard"
resource_ids = fields.Many2many('golem.resource')
date_start = fields.Date(required=True)
date_stop = fields.Date(required=True)
@api.multi
def print_resource_report(self):
""" Print Report """
self.ensure_one()
record = self[0]
if record.date_start > record.date_stop:
raise ValidationError(_('Stop Date cannot be set before Start Date.'))
else:
data = self.read(
['resource_ids', 'date_start', 'date_stop'])[0]
return self.env['report'].get_action(
self, 'golem_resource_report.golem_reservation_report',
data=data)

View File

@ -0,0 +1,51 @@
<?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_resource_report_wizard_view_form">
<field name="name">GOLEM resource Report Wizard Form</field>
<field name="model">golem.resource.report.wizard</field>
<field name="arch" type="xml">
<form string="Resource Report">
<group>
<group>
<field name="resource_ids" options="{'no_create' : True}">
<tree>
<field name="name"/>
</tree>
</field>
</group>
<group>
<field name="date_start" />
<field name="date_stop" />
</group>
</group>
<footer>
<button name="print_resource_report" string="Print Report"
type="object" class="oe_highlight" />
<button string="Close" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
</data>
</odoo>