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

Print/Download Multiple PDFs

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
onlinev17
4377 Widoki
Awatar
Wyatt McGehee

I'm stuck.

My db is currently hosted with Odoo Online v17.1, and I need to print/download a large number of sales orders as separate PDFs. I have multiple batches of 50-100 quotes each.

I find that from the list view, selecting multiple quotes/orders and using any of the Print button/menu options concatenates all selected items into a single PDF. While useful for most other report types, that is extremely annoying for quotes, sales orders, invoices, proforma invoices, purchase orders, etc.

I chased multiple solutions, none of which will work with Odoo Online. I tried implementing a Server Action. Turns out 'safe_eval.py' is tight as hell. No 'import' statements, nor 'base64' or 'zipfile' built-ins. Then I tried writing my own module. Turns out custom python isn't even allowed Online, only on .sh or On-premise.

But I can't switch to either of those, because my db is already on 17.1, and I've just learned that downgrading is not an option, and Odoo.sh / On-Premise do not support intermediary versions.

I also find that people have been asking about this for the last 5+ years. What gives??? This is a simple as hell module. Why is something like this not already part of the code base?


from odoo import models, fields, api
import base64
import zipfile
import io

class SaleOrder(models.Model):
    _inherit = 'sale.order'

    @api.multi
    def batch_print_pdfs(self):
        report_template = 'sale.report_saleorder'
        download_urls = []

        for order in self:
            pdf_content, _ = self.env.ref(report_template)._render_qweb_pdf([order.id])
            attachment = self.env['ir.attachment'].create({
                'name': f'SaleOrder_{order.name}.pdf',
                'type': 'binary',
                'datas': base64.b64encode(pdf_content),
                'res_model': 'sale.order',
                'res_id': order.id,
                'mimetype': 'application/pdf'
            })
            download_urls.append(f'/web/content/{attachment.id}?download=true')

        js_downloads = "".join([f"window.open('{url}');" for url in download_urls])
        return {
            'type': 'ir.actions.client',
            'tag': 'action_warn',
            'params': {
                'title': 'Downloading...',
                'message': 'Your files are being downloaded. Please check your browser\'s download manager.',
                'sticky': False,
                'next': {'type': 'ir.actions.client', 'tag': 'reload'}
            },
            'context': {'js': js_downloads},
        }

    @api.multi
    def batch_print_pdfs_zipped(self):
        report_template = 'sale.report_saleorder'
        attachments = []

        for order in self:
            pdf_content, _ = self.env.ref(report_template)._render_qweb_pdf([order.id])
            pdf_base64 = base64.b64encode(pdf_content)
            attachment = self.env['ir.attachment'].create({
                'name': f'SaleOrder_{order.name}.pdf',
                'type': 'binary',
                'datas': pdf_base64,
                'res_model': 'sale.order',
                'res_id': order.id,
                'mimetype': 'application/pdf'
            })
            attachments.append(attachment)

        zip_buffer = io.BytesIO()
        with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
            for attachment in attachments:
                pdf_data = base64.b64decode(attachment.datas)
                zip_file.writestr(attachment.name, pdf_data)

        zip_buffer.seek(0)
        zip_data = zip_buffer.read()
        zip_base64 = base64.b64encode(zip_data)

        zip_attachment = self.env['ir.attachment'].create({
            'name': 'sale_orders.zip',
            'type': 'binary',
            'datas': zip_base64,
            'res_model': 'sale.order',
            'res_id': self[0].id,
            'mimetype': 'application/zip'
        })

        return {
            'type': 'ir.actions.act_url',
            'url': f'/web/content/{zip_attachment.id}?download=true',
            'target': 'self',
        }


The only thing left to try would be via the API?

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ść
Subdomain for database and domain for website
online v17
Awatar
0
paź 24
2496
Can we completely disable new user registration on V17 online version?
online ecommerce v17
Awatar
Awatar
Awatar
Awatar
4
maj 25
4018
Website Customization Rozwiązane
web online v17
Awatar
Awatar
1
maj 24
2086
Access Error in Accounting - Journal Item (account.move.item) Rozwiązane
accounting online v17
Awatar
Awatar
1
maj 24
4676
Can I log (privately) updates to an Employee's Hourly Cost? Rozwiązane
online enterprise v17
Awatar
Awatar
1
kwi 24
2189
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