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

Failed to import data from xlsx file

S'inscrire

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

Cette question a été signalée
importxlsx13
1 Répondre
5579 Vues
Avatar
David lev

Hi, i'm using odoo 13.
I want to import an XLSX file, extract data from it and based on this data associate other data with other fields.


playlist.py:

from typing import Tuple
from xlrd import open_workbook
from odoo import api, fields, models, _, exceptions
class Playlist(models.Model):
xls_file = fields.Binary("File")
song_ids = fields.Many2many('music.song', 'music_playlist_song_rel', 'playlist_id', 'song_id',
string='Songs, ondelete='cascade')

def extract_songs_from_xlsx(self) -> Tuple[list, dict]:
workbook = open_workbook(file_contents=self.xls_file)
sheet = workbook.active
songs = {}
for row in sheet.iter_rows(min_row=2, values_only=True):
song_name = row[0]
song_artist = row[1]
songs.update({song_name: song_artist})

songs.pop(list(songs.keys())[-1]) # remove credit

matched_songs = []
for song_name, artist_name in songs.items():
matched_songs_names = self.env['music.song'].search(
[('name', '=', song_name)])

for song in matched_songs_names:
for artist in song.artist_ids:
if artist_name in artist:
matched_songs.append(song)
break

return matched_songs, {"searched_songs": len(sheet.iter_rows(min_row=2, values_only=True)) - 1,
"matched_songs": len(matched_songs)}


@api.onchange('xls_file')
def insert_songs(self):
if self.xls_file:
results = self.extract_songs_from_xlsx()
self.song_ids = results[0]
return {
'warning': {
'title': 'Warning',
'message': f'Found {results[1]["matched_songs"]} songs out of {results[1]["searched_songs"]} searched',
}}

playlist.xml:

field name="xls_file"/>f
field name="song_ids"/>


error:

  File "/usr/lib/python3/dist-packages/xlrd/book.py", line 1265, in bof_error
    raise XLRDError('Unsupported format, or corrupt file: ' + msg)
xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record; found b'UEsDBBQA'
Has anyone encountered this problem before and knows how to solve it?



0
Avatar
Ignorer
Avatar
Thomas Detry (det)
Meilleure réponse

Your file is still in base64. You need to:

from base64 import b64decode

book = xlrd.open_workbook(file_contents=b64decode(self.file) or b'')


0
Avatar
Ignorer
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é
How i can upload date data in dd-mm-yyyy H:m format from XLS File
import datetime xlsx
Avatar
Avatar
1
oct. 20
5583
How to create a product imported from a file xlsx Openerp V7.0
import 7.0 xlsx
Avatar
Avatar
Avatar
2
mars 15
4336
Need help importing product variants from an Excel fileroduits dans Odoo 16
import variant xlsx odoo16features
Avatar
Avatar
Avatar
2
déc. 23
2659
Impossible to import datetime field from xlsx file in odoo v16 Résolu
import datetime xlsx odoo16features
Avatar
Avatar
Avatar
Avatar
4
oct. 23
5502
Import Wizard Skip row that does not contain an "amount" greater than zero Résolu
import csv xlsx Odoo13.0
Avatar
Avatar
Avatar
Avatar
3
mars 21
4075
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