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 to create Excel report in odoo9 ?

Odoberať

Get notified when there's activity on this post

This question has been flagged
reportexcelodoo9
7 Replies
16099 Zobrazenia
Avatar
Jignesh Mehta

Hello


I have create one wizard and take a field binary file for store file name.

While opening wizard, the file name appears from default_get method.


My Code is shown below:-

class wiz_print_excel(models.TransientModel):

    _name = 'wiz.print.excel'


    @api.model

    def default_get(self, fields):

        rec = super(wiz_print_excel, self).default_get(fields)

        rec['name'] = 'Presentation.xls'

        rec['file'] = 'file'

    return rec


    file = fields.Binary('File')

    name = fields.Char(string='File Name', size=32)


    @api.multi

    def print_excel_report(self):

        workbook = xlwt.Workbook()

        worksheet = workbook.add_sheet('Sheet 1')

        worksheet.write_merge(0, 0, 2, 8, 'Lucent Jewels Inc', GREEN_TABLE_HEADER)

        workbook.save('/Downloads/Presentation.xls')


Click on Print button of wizard, File saved this location. But when i click on download, errors was occurred.

It gives different error front end as well as back end.


Front End Error:-

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
http://0.0.0.0:8069/web/static/src/js/framework/ajax.js:230
Traceback:
get_file/$target<@http://0.0.0.0:8069/web/static/src/js/framework/ajax.js:230:35
jQuery.event.dispatch@http://0.0.0.0:8069/web/static/lib/jquery/jquery.js:4640:50
jQuery.event.add/elemData.handle@http://0.0.0.0:8069/web/static/lib/jquery/jquery.js:4309:41


Back End Error :-

File "/usr/share/pyshared/werkzeug/serving.py", line 159, in run_wsgi

execute(app)

File "/usr/share/pyshared/werkzeug/serving.py", line 146, in execute

application_iter = app(environ, start_response)

File "/home/jigneshm/workspace/odoo/openerp/service/server.py", line 245, in app

return self.app(e, s)

File "/home/jigneshm/workspace/odoo/openerp/service/wsgi_server.py", line 184, in application

return application_unproxied(environ, start_response)

File "/home/jigneshm/workspace/odoo/openerp/service/wsgi_server.py", line 170, in application_unproxied

result = handler(environ, start_response)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1422, in __call__

return self.dispatch(environ, start_response)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1396, in __call__

return self.app(environ, start_wrapped)

File "/usr/share/pyshared/werkzeug/wsgi.py", line 411, in __call__

return self.app(environ, start_response)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 1586, in dispatch

result = ir_http._dispatch()

File "/home/jigneshm/workspace/odoo/addons/web_editor/models/ir_http.py", line 16, in _dispatch

return super(ir_http, self)._dispatch()

File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 186, in _dispatch

return self._handle_exception(e)

File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 157, in _handle_exception

return request._handle_exception(exception)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 743, in _handle_exception

return super(HttpRequest, self)._handle_exception(exception)

File "/home/jigneshm/workspace/odoo/openerp/addons/base/ir/ir_http.py", line 182, in _dispatch

result = request.dispatch()

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 774, in dispatch

r = self._call_function(**self.params)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 316, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/home/jigneshm/workspace/odoo/openerp/service/model.py", line 118, in wrapper

return f(dbname, *args, **kwargs)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 309, in checked_call

result = self.endpoint(*a, **kw)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 893, in __call__

return self.method(*args, **kw)

File "/home/jigneshm/workspace/odoo/openerp/http.py", line 471, in response_wrap

response = f(*args, **kw)

File "/home/jigneshm/key_concept_jc/web/controllers/main.py", line 1049, in content_common

response.set_cookie('fileToken', token)

AttributeError: 'NotFound' object has no attribute 'set_cookie'



Hope you understand my question.

Thanks in advance.

2
Avatar
Zrušiť
Avatar
Jose Vasquez
Best Answer

Hi

I spent a bit of code that I use, I worked for odoo9

import xlwt

from xlsxwriter.workbook import Workbook

from cStringIO import StringIO

import base64


def print_excel_report(self, cr, uid, ids, context=None):

    filename= 'detalle_cobranzas.xls'

    workbook= xlwt.Workbook(encoding="UTF-8")

    worksheet= workbook.add_sheet('Detalle de cobranzas')

    style = xlwt.easyxf('font:height 400, bold True, name Arial; align: horiz center, vert center;borders: top medium,right medium,bottom medium,left medium')

    worksheet.write_merge(0,1,0,7,'REPORT IN EXCEL',style)

    fp = StringIO()

    workbook.save(fp)

    export_id = self.pool.get('excel.extended').create(cr, uid, {'excel_file': base64.encodestring(fp.getvalue()), 'file_name': filename}, context=context)

    fp.close()

    return{

        'view_mode': 'form',

'res_id': export_id,

'res_model': 'excel.extended',

'view_type': 'form',

'type': 'ir.actions.act_window',

'context': context,

'target': 'new',

    }


class inventory_excel_extended(models.Model):

_name= "excel.extended"

excel_file = fields.Binary('Dowload report Excel')

file_name = fields.Char('Excel File', size=64)

in xml

        <!-- Add button in your xml form -->
        <button name="print_excel_report" string="Print Excel"/>
        
        <!-- xml excel -->
        <record id="view_excel_form_extended" model="ir.ui.view">
<field name="name">excel.extended.form</field>
<field name="model">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>
</form>
</field>
</record>
<record id="action_excel_form" model="ir.actions.act_window">
<field name="name">Reportes Excel</field>
<field name="view_id" ref="view_excel_form_extended"/>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="res_model">excel.extended</field>
<field name="target">new</field>
</record>

I hope you helps, Greetings.

2
Avatar
Zrušiť
Jignesh Mehta
Autor

Thank you so much Jose.

Jignesh Mehta
Autor

How to add image in the xls report. It gives me error :- Exception: String longer than 32767 characters

Jose Vasquez

Hi Jignesh, This could serve you. http://xlsxwriter.readthedocs.org/en/latest/page_setup.html

Avatar
Fernando
Best Answer

Hola Jose, use tu código, pero al pulsar el botón que creé no me genera el archivo xls. Podrías ayudarme con esa parte ?. Muchas gracias.

0
Avatar
Zrušiť
Avatar
Vu Nguyen
Best Answer

Hi,

I prefer to use report_xls -> https://github.com/OCA/reporting-engine

Regards

0
Avatar
Zrušiť
Odoo Honduras

Any user manual to use it??

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
In which case we use the attribute _depends in odoo classes ?
report odoo9
Avatar
0
okt 16
4620
Subtraction in Excell report ODOO 12
report excel Odoo12
Avatar
Avatar
1
aug 24
3273
How to insert image into the excel report? Solved
report excel images
Avatar
Avatar
Avatar
Avatar
3
okt 23
14840
How to download .xls file in a single click? Solved
report excel python2.7
Avatar
Avatar
Avatar
Avatar
Avatar
6
sep 22
29467
Error On Saving Excel Report in Odoo V12c
report excel odooV12
Avatar
Avatar
1
apr 19
4170
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