Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

how can we generate Excel report using a button?

Odoberať

Get notified when there's activity on this post

This question has been flagged
reportingexcelodoo11community
2 Replies
26642 Zobrazenia
Avatar
onkar

Hello,

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

0
Avatar
Zrušiť
Avatar
Mitul Shingala
Best Answer

Hello,


on the button call the method. and into the method write your code to generate the excel report.

here i am write some code from where you can get some basic idea.

import xlwt
from xlsxwriter.workbook import Workbook
from cStringIO import StringIO
import base64
class your_object(models.Model):
    _name = 'your.object.'
    @api.multi
    def generate_excel_report(self):
        filename= 'filename.xls'
        workbook= xlwt.Workbook(encoding="UTF-8")
        worksheet= workbook.add_sheet('Sheet 1')
        style = xlwt.easyxf('font: bold True, name Arial;)
        worksheet.write_merge(0,1,0,3,'your data that you want to show into excelsheet',style)
        fp = StringIO()
        workbook.save(fp)
        record_id = self.env['wizard.excel.report'].create({'excel_file': base64.encodestring(fp.getvalue()),
                                                                                                'file_name': filename},)
        fp.close()
        return {'view_mode': 'form',
                    'res_id': record_id,
                    'res_model': 'wizard.excel.report',
                    'view_type': 'form',
                    'type': 'ir.actions.act_window',
                    'context': context,
                  'target': 'new',
       }

class wizard_excel_report(models.Model):
    _name= "wizard.excel.report"
    excel_file = fields.Binary('excel file')
    file_name = fields.Char('Excel File', size=64)


make the form view(xml code) of "wizard_excel_report" object as per your needs

2
Avatar
Zrušiť
onkar
Autor

thanks

Avatar
Samo Arko
Best Answer

You'll need to write a python method in your model that generates an excel, saves it to a stream and save it to a binary field.

In the view you can call this method to with a button.

With python 2.7 for odoo 10:

import xlwt
import base64
import StringIO

@api.multi
def generate_excel(self):
    stream = StringIO.StringIO()
    book = xlwt.Workbook(encoding='utf-8')
    sheet = book.add_sheet(u'Sheet1')
    sheet.write(row, col, data)
    book.save(stream)
    self.your_binary_field = base64.encodestring(stream.getvalue())
    self.your_file_name = self.name

In the view you then have a button that calls that method

<field name="file_name" invisible="1"/>
<field name="document" filename="file_name"/>
<button name="generate_excel" type="object" string="Generate excel"/>

You'll need to adjust it for python3 and odoo 11 views. Hope it helps. 

1
Avatar
Zrušiť
onkar
Autor

thank you!

Samo Arko

no problem, had to figure how to do this just this week so glad to help.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
Creating Excel Reports Solved
accounting reporting excel
Avatar
Avatar
1
apr 23
12408
Print Excel Report odoo 14 cell sum
reporting excel v14
Avatar
Avatar
1
júl 22
3412
Print Excel Report odoo 14 Solved
reporting excel v14
Avatar
Avatar
1
júl 22
3171
Odoo 11 CE - Inventory Valuation Not Appearing on Balance Sheet
accounting reporting odoo11community
Avatar
Avatar
1
feb 20
4788
Expected Singleton Error for excel report
reporting invoicing excel Odoo13.0
Avatar
1
feb 22
61
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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