Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

Is it possible to make a file in .txt format?

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
exportprintfiletxt
9 Odpowiedzi
12509 Widoki
Awatar
Deborah Joy Adeva

wanted to export a txt file but whenever I made one it is downloaded in the server.

Is it possible to print/download it like qweb report where it is saved in the /downloads of the pc you're using.

0
Awatar
Odrzuć
Dan Čermák

I think this should be possible in the following way: you save the file on your server and generate a new http route that will send the file to the user. See: https://www.odoo.com/documentation/9.0/reference/http.html (the v10 documentation is pretty scarce). There might be a better way though and I have never done something like that, so no guarantees, that it will work.

Awatar
Jainesh Shah(Aktiv Software)
Najlepsza odpowiedź
Hello, 

You can try below code for downloading your file as odoo default report (sale order report)

f_read = Your test file # Test file 
file_data = f_read.read()
#Pass your text file data using encoding.
values = {
            'name': "Name of text file.txt",
            'datas_fname': 'print_file_name.txt',
            'res_model': 'ir.ui.view',
            'res_id': False,
            'type': 'binary',
            'public': True,
            'datas': file_data.encode('utf8').encode('base64'),
        }
Using your data create as attachment
attachment_id = self.env['ir.attachment'].sudo().create(values)
#Prepare your download URL
download_url = '/web/content/' + str(\attachment_id.id) + '?download=True'
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
Return so it will download in your system
return {
        "type": "ir.actions.act_url",
        "url": str(base_url)  +  str(download_url),
        "target": "new",
     }

Hope this will help you!
Thanks.
4
Awatar
Odrzuć
Deborah Joy Adeva
Autor

i've tested your code, but whenever i tried to print whats inside 'file_data', it prints nothing. does it mean that theres no data passed in 'file_data'?

Deborah Joy Adeva
Autor

It already worked. thank you so much.

Deborah Joy Adeva
Autor

Now I'm trying to put multiple rows in my txt file. but instead of making a new line, it's just in one line/row. what should I do? is the line: 'datas': file_data.encode('utf8').encode('base64'),

gave that result? I used \n and \t, I tried printing the file_data and it has the right output but in the txt file downloaded it's in one line only. thank you so much for helping me.

Jainesh Shah(Aktiv Software)

Are you trying write using python code then you can put code like this,

f_read.write("\tTest line\n") It will evaluate "\n",

And if you are using exisiting ".text" file then no need to write "\n" simply put your lines as per your format.

After encoding, you can see your file content using decode as below.

data_encode = file_data.encode('utf8').encode('base64')

data_decode = data_encode.decode('base64','strict').

Hope this will help you.

Deborah Joy Adeva
Autor

Hello.. should I put it in the values {} ?

I don't know where I should put

data_encode = file_data.encode('utf8').encode('base64')

data_decode = data_encode.decode('base64','strict')

thanks in advance.

Deborah Joy Adeva
Autor

Hello, I still have the same problem and when I tried that one it shows 'Incorrect padding' error.

Awatar
DaSchloz
Najlepsza odpowiedź

Aktiv Softwares solution worked for me with one twist: 

import base64

...
base64.b64encode(file_data.encode('utf8'))


0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
Syntax Error When Printing Quotes
export print
Awatar
0
mar 15
4944
How to generate a txt file and save it to Downloads directory
python file txt
Awatar
0
wrz 17
6012
Export or Print Inventory on Hand as of 1/1/22 - Odoo 14EE Rozwiązane
export print inventory reporting
Awatar
Awatar
1
kwi 22
2735
A way to print/export reports from reporting module
export print csv report
Awatar
Awatar
Awatar
2
lis 15
7847
create export csv file with new button
export create csv file
Awatar
Awatar
1
mar 15
7048
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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