forked from Yaltik/golem
code refactoring
This commit is contained in:
parent
1398cb945d
commit
e7464a62b3
@ -15,7 +15,7 @@
|
||||
#
|
||||
# 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
|
||||
@ -24,18 +24,18 @@ from odoo import models, api
|
||||
|
||||
|
||||
class GolemResevationReport(models.AbstractModel):
|
||||
"Golem Reservation Report"
|
||||
_name = 'report.golem_resource_report.golem_reservation_report'
|
||||
|
||||
def get_total_reservation(self, data):
|
||||
"Get Reservation Count"
|
||||
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_resource(self, data):
|
||||
"Get Resource List"
|
||||
lst = []
|
||||
domain = [('date_start', '>', data['date_start']),
|
||||
('date_stop', '<', data['date_stop']),
|
||||
@ -45,6 +45,7 @@ class GolemResevationReport(models.AbstractModel):
|
||||
return lst
|
||||
|
||||
def get_client_color(self, partner_number):
|
||||
"Get Client Color"
|
||||
colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750',
|
||||
'#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652']
|
||||
color = "#000000"
|
||||
@ -58,6 +59,7 @@ class GolemResevationReport(models.AbstractModel):
|
||||
return color
|
||||
|
||||
def get_data(self, data):
|
||||
"Get Resevation Data"
|
||||
lst = []
|
||||
domain = [('date_start', '>', data['date_start']),
|
||||
('date_stop', '<', data['date_stop']),
|
||||
@ -68,7 +70,7 @@ class GolemResevationReport(models.AbstractModel):
|
||||
partner_number = 0
|
||||
for partner_id in partner_ids:
|
||||
partner_colors[str(partner_id)] = self.get_client_color(partner_number)
|
||||
partner_number +=1
|
||||
partner_number += 1
|
||||
|
||||
res = {}
|
||||
for reservation in reservations:
|
||||
@ -86,6 +88,7 @@ class GolemResevationReport(models.AbstractModel):
|
||||
|
||||
@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'))
|
||||
docargs = {
|
||||
|
@ -40,7 +40,6 @@ 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_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">
|
||||
@ -48,7 +47,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<td t-attf-style="background-color:{{data['bgcolor']}}!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['bgcolor']"/><br/>
|
||||
</td>
|
||||
</t>
|
||||
</t>
|
||||
|
@ -16,13 +16,13 @@
|
||||
# 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 """
|
||||
""" GOLEM Resources Report Wizard """
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
class GolemResourceReportWizard(models.TransientModel):
|
||||
"""GOLEM Resource wizard : refusal reason for a reservation """
|
||||
"""GOLEM Report Wizard : Choose report parameters """
|
||||
_name = "golem.resource.report.wizard"
|
||||
|
||||
resource_ids = fields.Many2many('golem.resource')
|
||||
@ -31,6 +31,7 @@ class GolemResourceReportWizard(models.TransientModel):
|
||||
|
||||
@api.multi
|
||||
def print_report(self):
|
||||
""" Print Report """
|
||||
for record in self:
|
||||
start_date = fields.Datetime.from_string(record.date_start)
|
||||
stop_date = fields.Datetime.from_string(record.date_stop)
|
||||
@ -40,16 +41,6 @@ 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)
|
||||
|
Loading…
Reference in New Issue
Block a user