Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
How to export xlsx in Odoo14 Web

How to export xlsx data form my/order website portal

I added one button in sale order portal My Account -> Sales Orders page like this

<!-- Add the Export Button -->
<template id="portal_my_orders_inherit_export" inherit_id="sale.portal_my_orders" customize_show="True">
    <xpath expr="//t[@t-call='portal.portal_searchbar']" position="before">

        <button class="btn btn-primary mb-2 sale_export_btn_class" id="sale_export_btn_id" type="button">
            Export Sale
        </button>
    </xpath>
</template>

When i click on this button export a xlsx file with all the sale order of the logged user

Please help me to resolve this.

Thank you.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The xlsx report its a controller you should call it from your button or create a widget that response to your onClick event button to call the controller and return the response to the browser with the report inside it.

I hope this answer can be helpful for you.

about 4 years ago · Juan Pablo Isaza Report

0

You can use a <a> tag and define a controller function to render and download the XLSX report.

In the following, we suppose you already created an XLSX report using the report_xlsx module

Example:

<a role="button" t-if="orders"
   t-att-href="'/my/export_orders?order_ids=%s' % orders.ids"
   class="btn btn-primary mb-2 mt-2"
   target="_blank"
>

Alter the customer portal controller to define the /my/export_orders route

class CustomerPortalExtended(CustomerPortal):
    @http.route('/my/export_orders', type='http', auth="user", website=True)
    def export_orders(self, **kw):
        order_ids = ast.literal_eval(kw['order_ids'])
        report_sudo = request.env.ref(report_name).with_user(SUPERUSER_ID)
        report = report_sudo._render_xlsx(order_ids, {})[0]
        report_http_headers = [
            ('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
            ('Content-Length', len(report)),
            ('Content-Disposition', content_disposition("Orders.xlsx"))
        ]
        return request.make_response(report, headers=report_http_headers)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!