Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to create Excel report in odoo9 ?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
reportexcelodoo9
7 Réponses
16071 Vues
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
Ignorer
Avatar
Jose Vasquez
Meilleure réponse

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
Ignorer
Jignesh Mehta
Auteur

Thank you so much Jose.

Jignesh Mehta
Auteur

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
Meilleure réponse

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
Ignorer
Avatar
Vu Nguyen
Meilleure réponse

Hi,

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

Regards

0
Avatar
Ignorer
Odoo Honduras

Any user manual to use it??

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
In which case we use the attribute _depends in odoo classes ?
report odoo9
Avatar
0
oct. 16
4611
Subtraction in Excell report ODOO 12
report excel Odoo12
Avatar
Avatar
1
août 24
3271
How to insert image into the excel report? Résolu
report excel images
Avatar
Avatar
Avatar
Avatar
3
oct. 23
14815
How to download .xls file in a single click? Résolu
report excel python2.7
Avatar
Avatar
Avatar
Avatar
Avatar
6
sept. 22
29447
Error On Saving Excel Report in Odoo V12c
report excel odooV12
Avatar
Avatar
1
avr. 19
4159
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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