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