İçereği Atla
Odoo Menü
  • Portal
  • Ücretsiz deneyin
  • Uygulamalar
    Finans
    • Muhasebe
    • Faturalama
    • Masraf Yönetimi
    • Elektronik Çizelge (BI)
    • Belgeler
    • İmza
    Satış
    • Müşteri İlişkileri Yönetimi (CRM)
    • Satış
    • Satış Noktası Mağaza
    • Satış Noktası Restoran
    • Abonelikler
    • Kiralama
    Web Sitesi
    • Web Sitesi Oluşturucu
    • eTicaret
    • Blog
    • Forum
    • Canlı Sohbet
    • eÖğrenme
    Tedarik Zinciri
    • Envanter
    • Üretim
    • Ürün Yaşam Döngüsü Yönetimi
    • Satın Alma
    • Bakım
    • Kalite
    İnsan Kaynakları
    • Çalışanlar
    • İşe Alım
    • İzin
    • Değerlendirme
    • Referans
    • Filo Yönetimi
    Pazarlama
    • Sosyal Medyada Pazarlama
    • E-posta ile Pazarlama
    • SMS ile Pazarlama
    • Etkinlikler
    • Pazarlama Otomasyonu
    • Anket
    Hizmetler
    • Proje Yönetimi
    • Çalışma Çizelgeleri
    • Saha Hizmeti
    • Yardım Masası
    • Planlama
    • Randevular
    Verimlilik
    • Sohbet
    • Onay
    • Nesnelerin İnterneti
    • VoIP
    • Bilgi Bankası
    • WhatsApp
    Üçüncü taraf uygulamalar Odoo Stüdyo Odoo Bulut Platformu
  • Sektörler
    Perakende satış
    • Kitapçı
    • Giyim Mağazası
    • Mobilya Mağazası
    • Gıda Marketi
    • Hırdavat Dükkanı
    • Oyuncak Dükkanı
    Gıda ve Konaklama
    • Bar ve Pub
    • Restoran
    • Fast Food Restoranı
    • Konuk Evi
    • İçecek Distribütörü
    • Otel
    Gayrimenkul
    • Emlak Acentesi
    • Mimarlık Firması
    • İnşaat
    • Emlak Yönetimi
    • Bahçe Tasarımı
    • Mülk Sahipleri Derneği
    Uzmanlık
    • Muhasebe Firması
    • Odoo Partner
    • Pazarlama Ajansı
    • Hukuk Firması
    • Yetenek Kazanımı
    • Denetim ve Belgelendirme
    Üretim
    • Tekstil
    • Metal
    • Mobilyalar
    • Gıda
    • Bira fabrikası
    • Kurumsal Hediye
    Sağlık ve Spor
    • Spor Kulübü
    • Optik Mağazası
    • Fitness Merkezi
    • Sağlıklı Yaşam Merkezi
    • Eczane
    • Kuaför Salonu
    Ticaret
    • Tamirci
    • BT Donanım & Destek
    • Güneş Enerjisi Sistemleri
    • Ayakkabı İmalatçısı
    • Temizlik Hizmetleri
    • HVAC Hizmetleri
    Diğerleri
    • Kar Amacı Gütmeyen Kuruluş
    • Çevre Ajansı
    • Reklam Panosu Kiralama
    • Fotoğrafçılık
    • Bisiklet Kiralama
    • Yazılım Bayisi
    Tüm Sektörlere Göz Atın
  • Topluluk
    Öğrenim
    • Eğitim Araçları
    • Dokümantasyon
    • Sertifikasyonlar
    • Eğitim Etkinlikleri
    • Blog
    • Podcast
    Eğitim ve Gelişim
    • Eğitim Programı
    • Scale Up! İşletme Oyunu
    • Odoo'yu Ziyaret Edin
    Yazılım
    • İndirin
    • Sürümleri Kıyaslayın
    • Sürümler
    İş Birliği
    • Github
    • Forum
    • Etkinlikler
    • Çeviriler
    • Partner Olun
    • Partnerler için Hizmetler
    • Muhasebe Firmanızı Kaydettirin
    Hizmetler
    • Partner Bulun
    • Muhasebeci Bulun
    • Bir danışmanla görüşün
    • Kurulum Hizmetleri
    • Müşteri Referansları
    • Destek
    • Sürüm Yükseltme
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Demo randevusu alın
  • Fiyatlandırma
  • Yardım

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

  • Müşteri İlişkileri Yönetimi
  • e-Commerce
  • Muhasebe
  • Envanter
  • PoS
  • Proje Yönetimi
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiketler (View all)
odoo accounting v14 pos v15
About this forum
Yardım

Button in action menu to download all pickings attachments

Abone Ol

Get notified when there's activity on this post

Bu soru işaretlendi
actionpdfpickingdownload
1 Cevapla
5412 Görünümler
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
Vazgeç
Alexandru Gagea
Üretici

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)
En İyi Yanıt

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
Vazgeç
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.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Üye Ol
İlgili Gönderiler Cevaplar Görünümler Aktivite
Error on printing multiple records
action pdf
Avatar
0
Şub 25
1260
How to make downloading a pdf file Çözüldü
pdf download
Avatar
Avatar
2
Oca 24
15216
Configure a link to download a PDF file
pdf download Link
Avatar
0
May 24
2843
Picking PDF document with partial delivery
pdf picking partial
Avatar
0
Ara 15
4248
Download Pdf File On local Machine ?
pdf python download
Avatar
0
Mar 15
5347
Topluluk
  • Eğitim Araçları
  • Dokümantasyon
  • Forum
Açık Kaynak
  • İndirin
  • Github
  • Runbot
  • Çeviriler
Hizmetler
  • Odoo.sh Hosting
  • Destek
  • Sürüm Yükseltme
  • Özel Geliştirmeler
  • Eğitim
  • Muhasebeci Bulun
  • Partner Bulun
  • Partner Olun
Hakkında
  • Şirketimiz
  • Pazarlama Gereçleri
  • İletişim
  • Kariyer
  • Etkinlikler
  • Podcast
  • Blog
  • Müşteriler
  • Hukuki • Gizlilik
  • Güvenlik
الْعَرَبيّة 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, müşteri ilişkileri yönetimi, eTicaret, muhasebe, envanter, satış noktası, proje yönetimi gibi şirketinizin tüm ihtiyaçlarını karşılayan bir açık kaynak işletme uygulamaları paketidir.

Odoo’nun eşsiz değer önermesi, aynı anda hem kullanımının çok kolay olup hem de tamamen entegre olmasıdır.

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