Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

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

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Button in action menu to download all pickings attachments

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
actionpdfpickingdownload
1 Balas
5420 Tampilan
Avatar
Alexandru Gagea

Hello,


I am trying to select multiple pickings and download into a single pdf they're attachments

 ( shipping labels )


Bellow is my code which will download only one attachment.


Working on Odoo 13 CE.


def generate_awb_pdf(self):
sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', []))
pickings = self.env['stock.picking'].search([('origin', 'in', [o.name for o in sale_orders])])
attachment_ids = self.env['ir.attachment'].search(
[('res_model', '=', 'stock.picking'), ('res_id', 'in', [p.id for p in pickings])])
result = b''
for rec in attachment_ids:
result += rec.datas
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
attachment_obj = self.env['ir.attachment']
attachment_id = attachment_obj.sudo().create(
{'name': "name", 'store_fname': 'awb.pdf', 'datas': result})
download_url = '/web/content/' + str(attachment_id.id) + '?download=true'
return {
'name': 'Report',
'type': 'ir.actions.act_url',
'url': str(base_url) + str(download_url),
'target': 'self',
}



Thank you !


1
Avatar
Buang
Alexandru Gagea
Penulis

Hello Jainesh, 

I've changed the code as you suggested (makes sense..) , however, nothing is getting downloaded.


def generate_awb_pdf(self):

sale_orders = self.env['sale.order'].browse(self._context.get('active_ids', []))
pickings = self.env['stock.picking'].search([('origin', 'in', [o.name for o in sale_orders])])
attachment_ids = self.env['ir.attachment'].search(
[('res_model', '=', 'stock.picking'), ('res_id', 'in', [p.id for p in pickings])])
result = b''

for rec in attachment_ids:
result += rec.datas
attachment_obj = self.env['ir.attachment']
attachment_id = attachment_obj.sudo().create(
{'name': "name", 'store_fname': 'awb.pdf', 'datas': rec.datas})
download_url = '/web/content/' + str(attachment_id.id) + '?download=true'
self.get_report(download_url)

def get_report(self, download_url):
base_url = self.env['ir.config_parameter'].get_param('web.base.url')
return {
'name': 'Report',
'type': 'ir.actions.act_url',
'url': str(base_url) + str(download_url),
'target': 'new',
}

Avatar
Jainesh Shah(Aktiv Software)
Jawaban Terbai

Hello Alexandru,

The problem in your solution is that the data is being returned inside a loop, so once the data is returned the execution of loop will stop.

Please keep the return part in a separate method and call that method inside the loop so even after something is returned the main loop continues.

eg:

for rec in attachment_ids:
    #code to generate url
    self.get_report(url_of_report)

def get_report(self, url_of_report)
    return {
        'name': 'Report',
        'type': 'ir.actions.act_url',
        'url': url_of_report,
        'target': 'self',
}

Hope this solves your issue.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

0
Avatar
Buang
Jainesh Shah(Aktiv Software)

Hello @Alexandru

Based on your comment:

For the point:
I am trying to select multiple pickings and download into a single pdf they're attachments ( shipping labels )

- I understand you want all attachments as a single pdf file, Here you have made a few mistakes in code as:
1. In attachments you might have different file types like image, pdf, zip so creating a new attachment of pdf type directly by combining binary data is not a valid solution.

2. Also if you have only pdf attachment then you might also have user uploaded pdf or any other pdf documents related to picking.

I have made a server action which will download all pdf attachments in to a single attachment.

Please check below link for code.
-------------------------------------
https://drive.google.com/drive/folders/1gRGCd9Aet2oTxWMH8Wpsz1wFLLLMUVJi?usp=sharing
-------------------------------------

Note: Please install PyPDF2 lib if you do not have it in your system.

Please make required changes to the above code, I have tested this and it gives me a common pdf for all pdf type attachments in selected pickings.

Although the page numbers and details belong to individual pdfs you might need to find a work around for it if necessary.

Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Error on printing multiple records
action pdf
Avatar
0
Feb 25
1268
How to make downloading a pdf file Diselesaikan
pdf download
Avatar
Avatar
2
Jan 24
15229
Configure a link to download a PDF file
pdf download Link
Avatar
0
Mei 24
2853
Picking PDF document with partial delivery
pdf picking partial
Avatar
0
Des 15
4256
Download Pdf File On local Machine ?
pdf python download
Avatar
0
Mar 15
5352
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة 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 adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

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