Skip to content

Commit

Permalink
[FIX] mis_builder: let non-admins generate reports
Browse files Browse the repository at this point in the history
Normal users now don't get `AccessError` when trying to preview or print reports.

Fixes OCA#415.

@moduon MT-1527
  • Loading branch information
yajo committed Nov 9, 2022
1 parent d2072bb commit 145cf6a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions mis_builder/models/mis_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,11 @@ def _compute_all_kpi_ids(self):
@api.depends("move_lines_source")
def _compute_account_model(self):
for record in self:
record.account_model = record.move_lines_source.field_id.filtered(
lambda r: r.name == "account_id"
).relation
record.account_model = (
record.move_lines_source.sudo()
.field_id.filtered(lambda r: r.name == "account_id")
.relation
)

@api.onchange("subkpi_ids")
def _on_change_subkpi_ids(self):
Expand Down
2 changes: 1 addition & 1 deletion mis_builder/models/mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def _onchange_source(self):
def _get_aml_model_name(self):
self.ensure_one()
if self.source == SRC_ACTUALS:
return self.report_id.move_lines_source.model
return self.report_id.move_lines_source.sudo().model
elif self.source == SRC_ACTUALS_ALT:
return self.source_aml_model_name
return False
Expand Down
1 change: 1 addition & 0 deletions mis_builder/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
* `CorporateHub <https://corporatehub.eu/>`__

* Alexey Pelykh <[email protected]>
* Jairo Llopis (https://www.moduon.team/)
1 change: 1 addition & 0 deletions mis_builder/readme/newsfragments/access-error.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix access error when previewing or printing report.

0 comments on commit 145cf6a

Please sign in to comment.