Browse Source

report_xlsx: fix report context propagation on records

pull/259/head
Simone Orsi 5 years ago
parent
commit
4a1398cf17
  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) report_model = self.env.get(report_model_name)
if report_model is None: if report_model is None:
raise UserError(_('%s model was not found' % report_model_name)) 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 @api.model
def _get_report_from_name(self, report_name): 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', []) ids = data["context"].get('active_ids', [])
else: else:
ids = self.env.context.get('active_ids', []) 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): def create_xlsx_report(self, docids, data):
objs = self._get_objs_for_report(docids, data) objs = self._get_objs_for_report(docids, data)

Loading…
Cancel
Save