fonction de reporting

This commit is contained in:
eloyoussef 2018-04-12 18:25:57 +02:00
parent c669ddae2f
commit 01a34e0e3b
9 changed files with 236 additions and 14 deletions

View File

@ -18,3 +18,4 @@
#from . import models
from . import wizard
from . import reports

View File

@ -28,6 +28,7 @@
'installable': True,
'depends': ['golem_resource'],
'data': ['reports/golem_reservation_report.xml',
'reports/golem_reservation_report_menu.xml',
'views/golem_resource_report_menu.xml',
'wizard/golem_resource_report_wizard_views.xml']
}

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,79 @@
# -*- 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/>.
import time
from odoo import models, api
class GolemResevationReport(models.AbstractModel):
_name = 'report.golem_resource_report.golem_reservation_report'
def get_total_reservation(self, data):
domain = [('date_start', '>', data['date_start']),
('date_stop', '<', data['date_stop']),
('resource_id', 'in', data['resource_ids'])]
return self.env['golem.resource.reservation'].search_count(domain)
def get_data(self, data):
lst = []
domain = [('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')
res = {}
for reservation in reservations:
res = {
'name': reservation.name,
'resource_name': reservation.resource_id.name,
'client': reservation.partner_id.name,
'date_start': reservation.date_start,
'date_stop': reservation.date_stop
}
lst.append(res)
#self.total_student = 0
"""for student in student_search:
self.total_student += 1
res = {
'name': student.name,
'middle_name': student.middle_name,
'last_name': student.last_name,
'application_no': student.application_number,
}
lst.append(res)"""
return lst
@api.model
def render_html(self, docids, data=None):
model = self.env.context.get('active_model')
docs = self.env[model].browse(self.env.context.get('active_id'))
docargs = {
'doc_ids': self.ids,
'doc_model': model,
'docs': docs,
'time': time,
'data': data,
'date_start': data['date_start'],
'date_stop': data['date_stop'],
'get_total_reservation': self.get_total_reservation(data),
'get_data': self.get_data(data),
}
return self.env['report'] \
.render('golem_resource_report.golem_reservation_report', docargs)

View File

@ -1,8 +1,62 @@
<?xml version="1.0"?>
<?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>
<report id="action_golem_reservation_report"
string="Reservations"
model="golem.resource.report.wizard"
report_type="qweb-html"
name="golem_resource_report.report_golem_reservation_template"/>
<data>
<template id="golem_reservation_report">
<t t-call="report.html_container">
<t t-call="report.external_layout">
<div class="font">
<div class="page">
<br></br>
<table border="1" width="100%" cellpadding="0" bgcolor="#5F8CA3" >
<tbody>
<tr width="100%">
<td class="text-center" width="100%">
<center><b>Maison Phare toutes les reservations</b><br/>
<b>From Date: </b>
<span t-esc="from_date" />
<span t-raw="'%s' % date_start if date_start else ''" />
<b>To Date:</b>
<span t-raw="'%s' % date_stop if date_stop else ''" /></center>
</td>
</tr>
</tbody>
</table>
<table border="1" width="100%" cellpadding="0" bgcolor="#ededed" style="padding: 20px; background-color: #ededed; border-collapse:separate;">
<tbody>
<tr t-foreach="get_data" t-as="o">
<td class="text-left">
<span t-esc="o['resource_name']" />
</td>
<td>
<span t-raw="'%s' % o['date_start'] if o['date_start'] else ''" />
</td>
<td>
<span t-raw="'%s' % o['date_stop'] if o['date_stop'] else ''" />
</td>
</tr>
</tbody>
</table>
</div>
</div>
</t>
</t>
</template>
</data>
</odoo>

View File

@ -0,0 +1,49 @@
<?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>
<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

@ -1,3 +1,21 @@
<?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>

View File

@ -38,7 +38,10 @@ class GolemResourceReportWizard(models.TransientModel):
raise ValidationError(_("Stop Date cannot be set before \
Start Date."))
else:
domain = [('date_start', '>', record.date_start),
('date_stop', '<', record.date_stop),
('resource_id', 'in', record.selected_resource_ids.ids)]
data = self.env['golem.resource.reservation'].search(domain)
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

@ -18,7 +18,6 @@ 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>
@ -28,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<group>
<group>
<field name="resource_ids" >
<tree>
<tree options="{'no_create' : True}">
<field name="name"/>
</tree>
</field>
@ -46,6 +45,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</form>
</field>
</record>
</data>
</odoo>