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 import time
from random import randint
from odoo import models, api from odoo import models, api
class GolemResevationReport(models.AbstractModel): class GolemResevationReport(models.AbstractModel):
_name = 'report.golem_resource_report.golem_reservation_report' _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) 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): def get_data(self, data):
lst = [] lst = []
domain = [('date_start', '>', data['date_start']), domain = [('date_start', '>', data['date_start']),
@ -43,8 +62,10 @@ class GolemResevationReport(models.AbstractModel):
'name': reservation.name, 'name': reservation.name,
'resource_name': reservation.resource_id.name, 'resource_name': reservation.resource_id.name,
'client': reservation.partner_id.name, 'client': reservation.partner_id.name,
'client_id': self.get_client_color(reservation.partner_id.id),
'date_start': reservation.date_start, 'date_start': reservation.date_start,
'date_stop': reservation.date_stop 'date_stop': reservation.date_stop,
'day_start': reservation.day_start
} }
lst.append(res) lst.append(res)
return lst return lst
@ -63,6 +84,7 @@ class GolemResevationReport(models.AbstractModel):
'date_stop': data['date_stop'], 'date_stop': data['date_stop'],
'get_total_reservation': self.get_total_reservation(data), 'get_total_reservation': self.get_total_reservation(data),
'get_data': self.get_data(data), 'get_data': self.get_data(data),
'get_resource': self.get_resource(data),
} }
return self.env['report'] \ return self.env['report'] \
.render('golem_resource_report.golem_reservation_report', docargs) .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>
<table border="1" width="100%" cellpadding="0" bgcolor="#ededed" style="padding: 20px; background-color: #ededed; border-collapse:separate;"> <table border="1" width="100%" cellpadding="0" bgcolor="#ededed" style="padding: 20px; background-color: #ededed; border-collapse:separate;">
<tbody> <tbody>
<tr t-foreach="get_data" t-as="o"> <!--<tr t-foreach="get_resource" t-as="r">-->
<td class="text-left"> <tr t-foreach="get_resource" t-as="resource">
<span t-esc="o['resource_name']" /> <td><span t-esc="resource"/></td>
</td> <t t-foreach="get_data" t-as="data">
<td> <t t-if="data['resource_name']==resource">
<span t-raw="'%s' % o['date_start'] if o['date_start'] else ''" /> <td t-attf-style="background-color:{{data['client_id']}}!important;">
</td> <b>Date :</b><span t-esc="data['day_start']"/><br/>
<td> <b>On behalf of :</b><span t-esc="data['client']"/><br/>
<span t-raw="'%s' % o['date_stop'] if o['date_stop'] else ''" /> <b>client_id :</b><span t-esc="data['client_id']"/><br/>
</td> </td>
</t>
</t>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

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