Amélioration de l'affichage du rappoort

This commit is contained in:
eloyoussef 2018-04-13 19:18:59 +02:00
parent 94bdd6240a
commit ce325aa054
3 changed files with 45 additions and 13 deletions

View File

@ -18,9 +18,11 @@
import time
from random import randint
from odoo import models, api
class GolemResevationReport(models.AbstractModel):
_name = 'report.golem_resource_report.golem_reservation_report'
@ -31,6 +33,23 @@ class GolemResevationReport(models.AbstractModel):
return self.env['golem.resource.reservation'].search_count(domain)
def get_resource(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')
lst = reservations.mapped('resource_id.name')
return lst
def get_client_color(self, client_id):
client_id *= 777777
color = "#0" + str(client_id)
color = color[:7]
return color
def get_data(self, data):
lst = []
domain = [('date_start', '>', data['date_start']),
@ -43,8 +62,10 @@ class GolemResevationReport(models.AbstractModel):
'name': reservation.name,
'resource_name': reservation.resource_id.name,
'client': reservation.partner_id.name,
'client_id': self.get_client_color(reservation.partner_id.id),
'date_start': reservation.date_start,
'date_stop': reservation.date_stop
'date_stop': reservation.date_stop,
'day_start': reservation.day_start
}
lst.append(res)
return lst
@ -63,6 +84,7 @@ class GolemResevationReport(models.AbstractModel):
'date_stop': data['date_stop'],
'get_total_reservation': self.get_total_reservation(data),
'get_data': self.get_data(data),
'get_resource': self.get_resource(data),
}
return self.env['report'] \
.render('golem_resource_report.golem_reservation_report', docargs)

View File

@ -40,16 +40,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</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 ''" />
<!--<tr t-foreach="get_resource" t-as="r">-->
<tr t-foreach="get_resource" t-as="resource">
<td><span t-esc="resource"/></td>
<t t-foreach="get_data" t-as="data">
<t t-if="data['resource_name']==resource">
<td t-attf-style="background-color:{{data['client_id']}}!important;">
<b>Date :</b><span t-esc="data['day_start']"/><br/>
<b>On behalf of :</b><span t-esc="data['client']"/><br/>
<b>client_id :</b><span t-esc="data['client_id']"/><br/>
</td>
</t>
</t>
</tr>
</tbody>
</table>

View File

@ -40,8 +40,16 @@ class GolemResourceReportWizard(models.TransientModel):
else:
data = self.read(
['resource_ids', 'date_start', 'date_stop'])[0]
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')
lst = reservations.mapped('resource_id.name')
print '____________________________________'
print lst
return self.env['report'].get_action(
self, 'golem_resource_report.golem_reservation_report',
data=data)