0

I am using odoo 8.0 and I'm making a report for asset list. So far I have created the asset list report:

enter image description here

How do I add a button with function to export the report as either .pdf,.xls or .csv formats?

Here is a snippet code I have for the report view.

<record model="ir.actions.act_window" id="action_fleet_reporting_asset_listing">
  <field name="name">Asset Listing</field>
  <field name="res_model">fleet.asset</field>
  <field name="view_id" ref="fleet_asset_listing_report"></field>
  <field name="view_type">tree</field>
  <field name="view_mode">tree</field>
  <field name="context">{"search_default_parent_false" : True,}</field>
  <field name="help" type="html">
    <p>
      Odoo helps you managing the costs for your different vehicles
      Costs are generally created from services and contract and appears here.
    </p>
    <p>
      Thanks to the different filters, Odoo can only print the effective
      costs, sort them by type and by vehicle.
    </p>
  </field>
</record>
Philip Mutua
  • 6,016
  • 12
  • 41
  • 84

1 Answers1

0
<report id="report_fleet_asset_list"
    name="fleet.qweb_fleet_asset_list"
    model="fleet.asset"
    string="Assets"
    report_type="qweb-pdf" />

Then created the Template:

<?xml version="1.0" encoding="utf-8"?>
<!--Custom report.-->

<openerp>
    <data>
        <template id="qweb_fleet_asset_list">
            <t t-call="report.html_container">
                <t t-call="report.internal_layout">
                    <div class="page">
                        <h2>Aseet List</h2>
                        <div class="row mt4 mb4" t-as="o" t-foreach="docs">
                            <div class="col-md-6">
                                <t t-esc="o.name"/>
                            </div>
                            <div class="col-md-6">
                                <t t-esc="o.location" t-if="o.location"/>
                                <t t-if="not o.location">-</t>
                            </div>
                        </div>
                    </div>
                </t>
            </t>
        </template>
    </data>
</openerp>
Naglis
  • 2,583
  • 1
  • 19
  • 24
Philip Mutua
  • 6,016
  • 12
  • 41
  • 84