Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to create Excel report in odoo9 ?

Naroči se

Get notified when there's activity on this post

This question has been flagged
reportexcelodoo9
7 Odgovori
16016 Prikazi
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
Opusti
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
Opusti
Jignesh Mehta
Avtor

Thank you so much Jose.

Jignesh Mehta
Avtor

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
Opusti
Avatar
Vu Nguyen
Best Answer

Hi,

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

Regards

0
Avatar
Opusti
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!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
In which case we use the attribute _depends in odoo classes ?
report odoo9
Avatar
0
okt. 16
4595
Subtraction in Excell report ODOO 12
report excel Odoo12
Avatar
Avatar
1
avg. 24
3251
How to insert image into the excel report? Solved
report excel images
Avatar
Avatar
Avatar
Avatar
3
okt. 23
14764
How to download .xls file in a single click? Solved
report excel python2.7
Avatar
Avatar
Avatar
Avatar
Avatar
6
sep. 22
29414
Error On Saving Excel Report in Odoo V12c
report excel odooV12
Avatar
Avatar
1
apr. 19
4120
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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