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
|
# 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/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
""" Golem Reservation Report """
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from random import randint
|
from random import randint
|
||||||
@ -24,18 +24,18 @@ from odoo import models, api
|
|||||||
|
|
||||||
|
|
||||||
class GolemResevationReport(models.AbstractModel):
|
class GolemResevationReport(models.AbstractModel):
|
||||||
|
"Golem Reservation Report"
|
||||||
_name = 'report.golem_resource_report.golem_reservation_report'
|
_name = 'report.golem_resource_report.golem_reservation_report'
|
||||||
|
|
||||||
def get_total_reservation(self, data):
|
def get_total_reservation(self, data):
|
||||||
|
"Get Reservation Count"
|
||||||
domain = [('date_start', '>', data['date_start']),
|
domain = [('date_start', '>', data['date_start']),
|
||||||
('date_stop', '<', data['date_stop']),
|
('date_stop', '<', data['date_stop']),
|
||||||
('resource_id', 'in', data['resource_ids'])]
|
('resource_id', 'in', data['resource_ids'])]
|
||||||
return self.env['golem.resource.reservation'].search_count(domain)
|
return self.env['golem.resource.reservation'].search_count(domain)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_resource(self, data):
|
def get_resource(self, data):
|
||||||
|
"Get Resource List"
|
||||||
lst = []
|
lst = []
|
||||||
domain = [('date_start', '>', data['date_start']),
|
domain = [('date_start', '>', data['date_start']),
|
||||||
('date_stop', '<', data['date_stop']),
|
('date_stop', '<', data['date_stop']),
|
||||||
@ -45,6 +45,7 @@ class GolemResevationReport(models.AbstractModel):
|
|||||||
return lst
|
return lst
|
||||||
|
|
||||||
def get_client_color(self, partner_number):
|
def get_client_color(self, partner_number):
|
||||||
|
"Get Client Color"
|
||||||
colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750',
|
colors = ['#FFFF5B', '#81EC54', '#47C8C8', '#FB5A66', '#E8E750',
|
||||||
'#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652']
|
'#CF4ACF', '#9655D2', '#FFA15B', '#5F68D5', '#60E652']
|
||||||
color = "#000000"
|
color = "#000000"
|
||||||
@ -58,6 +59,7 @@ class GolemResevationReport(models.AbstractModel):
|
|||||||
return color
|
return color
|
||||||
|
|
||||||
def get_data(self, data):
|
def get_data(self, data):
|
||||||
|
"Get Resevation Data"
|
||||||
lst = []
|
lst = []
|
||||||
domain = [('date_start', '>', data['date_start']),
|
domain = [('date_start', '>', data['date_start']),
|
||||||
('date_stop', '<', data['date_stop']),
|
('date_stop', '<', data['date_stop']),
|
||||||
@ -86,6 +88,7 @@ class GolemResevationReport(models.AbstractModel):
|
|||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def render_html(self, docids, data=None):
|
def render_html(self, docids, data=None):
|
||||||
|
"Render HTML"
|
||||||
model = self.env.context.get('active_model')
|
model = self.env.context.get('active_model')
|
||||||
docs = self.env[model].browse(self.env.context.get('active_id'))
|
docs = self.env[model].browse(self.env.context.get('active_id'))
|
||||||
docargs = {
|
docargs = {
|
||||||
|
@ -40,7 +40,6 @@ 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_resource" t-as="r">-->
|
|
||||||
<tr t-foreach="get_resource" t-as="resource">
|
<tr t-foreach="get_resource" t-as="resource">
|
||||||
<td><span t-esc="resource"/></td>
|
<td><span t-esc="resource"/></td>
|
||||||
<t t-foreach="get_data" t-as="data">
|
<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;">
|
<td t-attf-style="background-color:{{data['bgcolor']}}!important;">
|
||||||
<b>Date :</b><span t-esc="data['day_start']"/><br/>
|
<b>Date :</b><span t-esc="data['day_start']"/><br/>
|
||||||
<b>On behalf of :</b><span t-esc="data['client']"/><br/>
|
<b>On behalf of :</b><span t-esc="data['client']"/><br/>
|
||||||
<b>client_id :</b><span t-esc="data['bgcolor']"/><br/>
|
|
||||||
</td>
|
</td>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# 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 import models, fields, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
class GolemResourceReportWizard(models.TransientModel):
|
class GolemResourceReportWizard(models.TransientModel):
|
||||||
"""GOLEM Resource wizard : refusal reason for a reservation """
|
"""GOLEM Report Wizard : Choose report parameters """
|
||||||
_name = "golem.resource.report.wizard"
|
_name = "golem.resource.report.wizard"
|
||||||
|
|
||||||
resource_ids = fields.Many2many('golem.resource')
|
resource_ids = fields.Many2many('golem.resource')
|
||||||
@ -31,6 +31,7 @@ class GolemResourceReportWizard(models.TransientModel):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def print_report(self):
|
def print_report(self):
|
||||||
|
""" Print Report """
|
||||||
for record in self:
|
for record in self:
|
||||||
start_date = fields.Datetime.from_string(record.date_start)
|
start_date = fields.Datetime.from_string(record.date_start)
|
||||||
stop_date = fields.Datetime.from_string(record.date_stop)
|
stop_date = fields.Datetime.from_string(record.date_stop)
|
||||||
@ -40,16 +41,6 @@ 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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user