Skip to Content
Menu
This question has been flagged
3099 Views

using below code i am getting only last attachment of my model how do i get all attachments in single pdf. note (all attachments here in pdf format)

my code:

def action_attachment_down (self):

sale_orders = self.env ['sale.order']. search ([])

result = b ''

for rec in sale_orders:

        if rec.attachment_ids:

        result.write (rec.attachment_ids)

        _logger = logging.info ("record id Here .........................")

    _logger = logging.info (rec.id)

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", 'datas_fname': 'sale_attachments.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': 'new',

}

rference url: \https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-download-all-records-attachments-of-sale-order-model-using-button-v12-174670

Avatar
Discard
Related Posts Replies Views Activity
2
Dec 23
12010
0
Oct 23
33
3
Oct 23
787
1
Oct 23
569
1
Aug 23
983