[IMP] mis_builder: pdf export embryo (working but not styled yet)
parent
62b5ab8c29
commit
cf975bd822
|
@ -39,6 +39,7 @@
|
||||||
'views/mis_builder.xml',
|
'views/mis_builder.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'security/mis_builder_security.xml',
|
'security/mis_builder_security.xml',
|
||||||
|
'report/report_mis_report_instance.xml',
|
||||||
],
|
],
|
||||||
'test': [
|
'test': [
|
||||||
],
|
],
|
||||||
|
|
|
@ -28,6 +28,7 @@ import re
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
from openerp import api
|
||||||
from openerp.api import Environment
|
from openerp.api import Environment
|
||||||
from openerp.osv import orm, fields
|
from openerp.osv import orm, fields
|
||||||
from openerp import tools
|
from openerp import tools
|
||||||
|
@ -711,6 +712,7 @@ class mis_report_instance(orm.Model):
|
||||||
'target': 'new',
|
'target': 'new',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@api.cr_uid_id_context
|
||||||
def compute(self, cr, uid, _id, context=None):
|
def compute(self, cr, uid, _id, context=None):
|
||||||
assert isinstance(_id, (int, long))
|
assert isinstance(_id, (int, long))
|
||||||
if context is None:
|
if context is None:
|
||||||
|
|
|
@ -23,3 +23,4 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from . import mis_builder_xls
|
from . import mis_builder_xls
|
||||||
|
from . import report_mis_report_instance
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
# -*- encoding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# mis_builder module for Odoo, Management Information System Builder
|
||||||
|
# Copyright (C) 2014-2015 ACSONE SA/NV (<http://acsone.eu>)
|
||||||
|
#
|
||||||
|
# This file is a part of mis_builder
|
||||||
|
#
|
||||||
|
# mis_builder is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License v3 or later
|
||||||
|
# as published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# mis_builder 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 v3 or later for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# v3 or later along with this program.
|
||||||
|
# If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from openerp import api, models
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ReportMisReportInstance(models.AbstractModel):
|
||||||
|
|
||||||
|
_name = 'report.mis_builder.report_mis_report_instance'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def render_html(self, data=None):
|
||||||
|
docs = self.env['mis.report.instance'].browse(self._ids)
|
||||||
|
docs_computed = {}
|
||||||
|
for doc in docs:
|
||||||
|
docs_computed[doc.id] = doc.compute()[0]
|
||||||
|
_logger.info("%s", docs_computed)
|
||||||
|
docargs = {
|
||||||
|
'doc_ids': self._ids,
|
||||||
|
'doc_model': 'mis.report.instance',
|
||||||
|
'docs': docs,
|
||||||
|
'docs_computed': docs_computed,
|
||||||
|
}
|
||||||
|
return self.env['report'].\
|
||||||
|
render('mis_builder.report_mis_report_instance', docargs)
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<template id="report_mis_report_instance">
|
||||||
|
<t t-call="report.html_container">
|
||||||
|
<t t-foreach="docs" t-as="o">
|
||||||
|
<t t-call="report.external_layout">
|
||||||
|
<div class="page">
|
||||||
|
<h2 t-field="o.name"></h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<t t-foreach="docs_computed[o.id]['header']" t-as="h">
|
||||||
|
<th>
|
||||||
|
<div>
|
||||||
|
<t t-esc="h_value['kpi_name']"/>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<th t-foreach="h_value['cols']" t-as="col">
|
||||||
|
<div>
|
||||||
|
<t t-esc="col['name']"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<t t-esc="col['date']"/>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
</t>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr t-foreach="docs_computed[o.id]['content']" t-as="c">
|
||||||
|
<td t-att-style="c_value['default_style']">
|
||||||
|
<div>
|
||||||
|
<t t-esc="c_value['kpi_name']"/>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<t t-foreach="c_value['cols']" t-as="value">
|
||||||
|
<td t-att-style="c_value['default_style']">
|
||||||
|
<div t-att-style="value_value.get('style')">
|
||||||
|
<t t-esc="value_value['val_r']"/>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</t>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</t>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -100,7 +100,7 @@
|
||||||
<menuitem id="mis_report_view_menu" parent="account.menu_account_reports" name="MIS Report Templates" action="mis_report_view_action" sequence="21"/>
|
<menuitem id="mis_report_view_menu" parent="account.menu_account_reports" name="MIS Report Templates" action="mis_report_view_action" sequence="21"/>
|
||||||
|
|
||||||
<record id="xls_export" model="ir.actions.report.xml">
|
<record id="xls_export" model="ir.actions.report.xml">
|
||||||
<field name="name">Export report instance result</field>
|
<field name="name">MIS report instance XLS report</field>
|
||||||
<field name="model">mis.report.instance</field>
|
<field name="model">mis.report.instance</field>
|
||||||
<field name="type">ir.actions.report.xml</field>
|
<field name="type">ir.actions.report.xml</field>
|
||||||
<field name="report_name">mis.report.instance.xls</field>
|
<field name="report_name">mis.report.instance.xls</field>
|
||||||
|
@ -108,6 +108,15 @@
|
||||||
<field name="auto" eval="False"/>
|
<field name="auto" eval="False"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="qweb_pdf_export" model="ir.actions.report.xml">
|
||||||
|
<field name="name">MIS report instance QWEB PDF report</field>
|
||||||
|
<field name="model">mis.report.instance</field>
|
||||||
|
<field name="type">ir.actions.report.xml</field>
|
||||||
|
<field name="report_name">mis_builder.report_mis_report_instance</field>
|
||||||
|
<field name="report_type">qweb-pdf</field>
|
||||||
|
<field name="auto" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
<record model="ir.ui.view" id="mis_report_instance_result_view_form">
|
<record model="ir.ui.view" id="mis_report_instance_result_view_form">
|
||||||
<field name="name">mis.report.instance.result.view.form</field>
|
<field name="name">mis.report.instance.result.view.form</field>
|
||||||
<field name="model">mis.report.instance</field>
|
<field name="model">mis.report.instance</field>
|
||||||
|
@ -115,6 +124,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="MIS Report Result" version="7.0">
|
<form string="MIS Report Result" version="7.0">
|
||||||
<widget type="mis_report"></widget>
|
<widget type="mis_report"></widget>
|
||||||
|
<button icon="gtk-print" name="%(qweb_pdf_export)d" string="Print" type="action" colspan="2"/>
|
||||||
<button icon="gtk-execute" name="%(xls_export)d" string="XLS Export" type="action" colspan="2"/>
|
<button icon="gtk-execute" name="%(xls_export)d" string="XLS Export" type="action" colspan="2"/>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
@ -152,6 +162,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="oe_right oe_button_box" name="buttons">
|
<div class="oe_right oe_button_box" name="buttons">
|
||||||
<button type="object" name="preview" string="Preview" icon="gtk-print-preview" />
|
<button type="object" name="preview" string="Preview" icon="gtk-print-preview" />
|
||||||
|
<button type="action" name="%(qweb_pdf_export)d" string="Print" icon="gtk-print" />
|
||||||
<button type="action" name="%(xls_export)d" string="XLS Export" icon="gtk-execute" />
|
<button type="action" name="%(xls_export)d" string="XLS Export" icon="gtk-execute" />
|
||||||
<button type="action" name="%(mis_report_instance_add_to_dashboard_action)d" string="Add to dashboard" icon="gtk-add" />
|
<button type="action" name="%(mis_report_instance_add_to_dashboard_action)d" string="Add to dashboard" icon="gtk-add" />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue