Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

ODOO 12 how can we generate Excel report

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
excel
7 Risposte
16367 Visualizzazioni
Avatar
Hoang Quan


Hello,

I want to generate excel report on button click, can any one help me out how this can be done. I'm using odoo 12

Thanks 


0
Avatar
Abbandona
Avatar
Jignesh Mehta
Risposta migliore

Hello Hoang Quan,


Please find below code for the excel report of particular product. Add button in Product form view with method name "product_template_excel_report".

PY File :-
==========

from odoo import models, fields, api, _
from odoo.exceptions import UserError
from datetime import date, timedelta, datetime
import datetime
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
import tempfile
from odoo.tools.misc import xlwt
import io
import base64
import time
from dateutil.relativedelta import relativedelta
from pytz import timezone

class ProductTemplate(models.TransientModel):
    _inherit = 'product.template'

    @api.multi
    def product_template_excel_report(self):
        filename= 'Product Report ' + str(self.name) + '.xls'
        workbook= xlwt.Workbook()

        worksheet= workbook.add_sheet('Product Report')
        font = xlwt.Font()
        font.bold = True
        for_left = xlwt.easyxf("font: bold 1, color black; borders: top double, bottom double, left double, right double; align: horiz left")
        for_left_not_bold = xlwt.easyxf("font: color black; align: horiz left")
        for_center_bold = xlwt.easyxf("font: bold 1, color black; align: horiz center")
        GREEN_TABLE_HEADER = xlwt.easyxf(
            'font: bold 1, name Tahoma, height 250;'
            'align: vertical center, horizontal center, wrap on;'
            'borders: top double, bottom double, left double, right double;'
            )
        style = xlwt.easyxf('font:height 400, bold True, name Arial; align: horiz center, vert center;borders: top medium,right medium,bottom medium,left medium')

        alignment = xlwt.Alignment()  # Create Alignment
        alignment.horz = xlwt.Alignment.HORZ_RIGHT
        style = xlwt.easyxf('align: wrap yes')
        style.num_format_str = '0.00'

         worksheet.row(0).height = 320
        worksheet.col(0).width = 4000
        worksheet.col(1).width = 4000
        borders = xlwt.Borders()
        borders.bottom = xlwt.Borders.MEDIUM
        border_style = xlwt.XFStyle()  # Create Style
        border_style.borders = borders

        product_title = 'Product Report ' + str(self.name)
        worksheet.write_merge(0,1,0,2,product_title,GREEN_TABLE_HEADER)

        row = 2

         worksheet.write(row, 0, 'Product Name' or '',for_left)
        worksheet.write(row, 1, 'Sales Price' or '',for_left)

        row = row + 1
        worksheet.write(row, 0, self.name or '',for_left_not_bold)
        worksheet.write(row, 1, self.list_price or '',for_left_not_bold)

        fp = io.BytesIO()
        workbook.save(fp)
        product_id = self.env['product.excel.extended'].create({'excel_file': base64.encodestring(fp.getvalue()), 'file_name': filename})
        fp.close()

        return{
            'view_mode': 'form',
            'res_id': product_id.id,
            'res_model': 'product.excel.extended',
            'view_type': 'form',
            'type': 'ir.actions.act_window',
             'context': self._context,
             'target': 'new',
         }


class ProductExcelExtended(models.Model):
        _name = 'product.excel.extended'
        _description = "Product Excel Extended"

         excel_file = fields.Binary('Download Report :- ')
         file_name = fields.Char('Excel File', size=64)



XML File :-
===========

<?xml version="1.0" encoding="utf-8"?>
<odoo>

     <!-- Excel Report Download Wizard Form View-->
     <record id="view_product_excel_form_extended" model="ir.ui.view">
     <field name="name">product.excel.extended.form</field>
     <field name="model">product.excel.extended</field>
     <field name="arch" type="xml">
     <form string="Excel Report file">
         <group>
             <field name="excel_file" readonly="1" filename="file_name"/>
             <field name="file_name" invisible="1"/>
         </group>
         <footer>
             <button string="Cancel" class="oe_link oe_highlight" special="cancel"/>
        </footer>
         </form>
         </field>
    </record>

     <!-- Excel Report Download Wizard Action View-->
     <record id="action_product_excel_form" model="ir.actions.act_window">
         <field name="name">Reports Excel</field>
         <field name="view_id" ref="view_product_excel_form_extended"/>
         <field name="view_type">form</field>
         <field name="view_mode">form</field>
         <field name="res_model">product.excel.extended</field>
         <field name="target">new</field>
     </record>

</odoo>

CSV File :-
===========

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_excel_extended,access.product.excel.extended,model_product_excel_extended,,1,1,1,1


Hope it will helps for you.

Thanks,

1
Avatar
Abbandona
Hoang Quan
Autore

thank you. i added your code. But in view file excel not display. I can't download it :( how to download ?

Please help me. Thanks

Nikunj Dhameliya

This URL will download a file if it is generated for the record, you have to set filename and record id of product.excel.extended model

localhost:8069/web/content/?model=product.excel.extended&download=true&field=excel_file&id=Enter Recordid&filename=Enterexcelfilename

Avatar
Niyas Raphy (Walnut Software Solutions)
Risposta migliore

Hi,

If you are looking how to generate excel report in odoo, see this: How To Create Excel/XLS Report in Odoo

Thanks

1
Avatar
Abbandona
Hoang Quan
Autore

it's not for me. I need get xls for tree view. Can u help me ?

Avatar
Anusha
Risposta migliore

Hi,

   You can just refer the Odoo Apps store for any example modules. here is one .please check it and make necessary changes   XLSX REPORT SAMPLE     

0
Avatar
Abbandona
Avatar
Hoang Quan
Autore Risposta migliore

[img]https://i.imgur.com/1YFNIwd.png[/img]


Hello Jignesh Mehta
I added your code. But it's nothing. Help me pls. Thanks

0
Avatar
Abbandona
Jignesh Mehta

Have you add access rights from csv file?

Hoang Quan
Autore

yes i do?. All fields already exist in Database. U can see my image https://i.imgur.com/1YFNIwd.png

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Cant download excel data from v11 using chrome anymore Risolto
excel
Avatar
Avatar
1
nov 22
3205
how to write an excel file into a field who is a field.Binary()?
excel
Avatar
0
feb 17
4037
How to create execel report in openerp7
excel
Avatar
0
mar 15
4569
How to use the module report_xls to generate XLS report in openerp ?
excel
Avatar
0
mar 15
5823
I have hard time getting know of this platform
excel importing
Avatar
Avatar
Avatar
2
set 23
1873
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now