From 2ad4bd4846074c4e4334aff13e32cc3335657c73 Mon Sep 17 00:00:00 2001
From: Nicolas Martinelli <nim@odoo.com>
Date: Wed, 11 May 2016 10:11:24 +0200
Subject: [PATCH] [FIX] account: print multiple GL

When several accounts are selected to print their GL, the GL of only one
is printed. This is due to two issues:
- 'active_id' is retrieved instead of 'active_ids'
- the method `get_action` is called with the wrong records. `self`
  refers to the wizard, not to the accounts selected.

opw-676061
---
 addons/account/report/account_general_ledger.py        | 2 +-
 addons/account/wizard/account_report_general_ledger.py | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/addons/account/report/account_general_ledger.py b/addons/account/report/account_general_ledger.py
index 9bd3c329ee02..ce9a3db095cf 100644
--- a/addons/account/report/account_general_ledger.py
+++ b/addons/account/report/account_general_ledger.py
@@ -110,7 +110,7 @@ class ReportGeneralLedger(models.AbstractModel):
     @api.multi
     def render_html(self, data):
         self.model = self.env.context.get('active_model')
-        docs = self.env[self.model].browse(self.env.context.get('active_id'))
+        docs = self.env[self.model].browse(self.env.context.get('active_ids', []))
 
         init_balance = data['form'].get('initial_balance', True)
         sortby = data['form'].get('sortby', 'sort_date')
diff --git a/addons/account/wizard/account_report_general_ledger.py b/addons/account/wizard/account_report_general_ledger.py
index 0f9d959c7f7e..e6919740480b 100644
--- a/addons/account/wizard/account_report_general_ledger.py
+++ b/addons/account/wizard/account_report_general_ledger.py
@@ -19,4 +19,5 @@ class AccountReportGeneralLedger(models.TransientModel):
         data['form'].update(self.read(['initial_balance', 'sortby'])[0])
         if data['form'].get('initial_balance') and not data['form'].get('date_from'):
             raise UserError(_("You must define a Start Date"))
-        return self.env['report'].with_context(landscape=True).get_action(self, 'account.report_generalledger', data=data)
+        records = self.env[data['model']].browse(data.get('ids', []))
+        return self.env['report'].with_context(landscape=True).get_action(records, 'account.report_generalledger', data=data)
-- 
GitLab