summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsbbaro <sbb@odoo.com>2019-01-23 14:20:33 +0100
committersbbaro <sbb@odoo.com>2019-01-23 14:20:33 +0100
commitc4d2c2cf13b5eed8e9726577a6a67384ec3067d2 (patch)
tree01d22c6c30710ec3282f53ee77a6933b533e05c0
parent6db1b8343b62dfc10046ac1e277181d15e619942 (diff)
[FIX] base ir.actions.report order pdfs when attachment_use option selected
A couple of small changes: - only run the search if streams is not empty - change streams for stream_list in the if for the final merging
-rw-r--r--odoo/addons/base/models/ir_actions_report.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/odoo/addons/base/models/ir_actions_report.py b/odoo/addons/base/models/ir_actions_report.py
index 98ea6c176a2..e5af01b2547 100644
--- a/odoo/addons/base/models/ir_actions_report.py
+++ b/odoo/addons/base/models/ir_actions_report.py
@@ -588,10 +588,16 @@ class IrActionsReport(models.Model):
content = base64.decodestring(attachment_id.datas)
streams[res_id] = io.BytesIO(content)
+ # A list is made with the unmapped streams and, if streams is not empty, its
+ # content, sorted by the table _order of the mapped records
+ if streams:
+ stream_list = unmapped_streams + [streams[rec_id.id] for rec_id in self.env[self.model].search([('id', 'in', list(streams.keys()))])]
+ else:
+ stream_list = unmapped_streams
+
# Build the final pdf.
# If only one stream left, no need to merge them (and then, preserve embedded files).
- stream_list = unmapped_streams + [streams[rec_id.id] for rec_id in self.env[self.model].search([('id', 'in', list(streams.keys()))])]
- if len(streams) == 1:
+ if len(stream_list) == 1:
result = stream_list[0].getvalue()
else:
writer = PdfFileWriter()