Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

211
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda