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

Failed to import data from xlsx file

Odoberať

Get notified when there's activity on this post

This question has been flagged
importxlsx13
1 Odpoveď
5591 Zobrazenia
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
Zrušiť
Avatar
Thomas Detry (det)
Best Answer

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
Zrušiť
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
How i can upload date data in dd-mm-yyyy H:m format from XLS File
import datetime xlsx
Avatar
Avatar
1
okt 20
5593
How to create a product imported from a file xlsx Openerp V7.0
import 7.0 xlsx
Avatar
Avatar
Avatar
2
mar 15
4342
Need help importing product variants from an Excel fileroduits dans Odoo 16
import variant xlsx odoo16features
Avatar
Avatar
Avatar
2
dec 23
2667
Impossible to import datetime field from xlsx file in odoo v16 Solved
import datetime xlsx odoo16features
Avatar
Avatar
Avatar
Avatar
4
okt 23
5515
Import Wizard Skip row that does not contain an "amount" greater than zero Solved
import csv xlsx Odoo13.0
Avatar
Avatar
Avatar
Avatar
3
mar 21
4076
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