Browse Source

Merge PR #259 into 11.0

Signed-off-by sbidoul
11.0
OCA-git-bot 5 years ago
parent
commit
d969b21b5e
  1. 6
      report_xlsx/models/ir_report.py
  2. 4
      report_xlsx/report/report_xlsx.py

6
report_xlsx/models/ir_report.py

@ -16,9 +16,9 @@ class ReportAction(models.Model):
report_model = self.env.get(report_model_name)
if report_model is None:
raise UserError(_('%s model was not found' % report_model_name))
return report_model.with_context({
'active_model': self.model
}).create_xlsx_report(docids, data)
return report_model.with_context(
active_model=self.model,
).create_xlsx_report(docids, data)
@api.model
def _get_report_from_name(self, report_name):

4
report_xlsx/report/report_xlsx.py

@ -37,7 +37,9 @@ class ReportXlsxAbstract(models.AbstractModel):
ids = data["context"].get('active_ids', [])
else:
ids = self.env.context.get('active_ids', [])
return self.env[self.env.context.get('active_model')].browse(ids)
# propagate context anyway
# let it fail explicitely if `active_model` is not there
return self.env[self.env.context['active_model']].browse(ids)
def create_xlsx_report(self, docids, data):
objs = self._get_objs_for_report(docids, data)

Loading…
Cancel
Save