From 5b22eab57fc65b3ce93a09a1facf9afe3f507aa7 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Wed, 7 Feb 2024 12:54:10 +0100 Subject: [PATCH] [FIX] mis_builder: add sudo to access field_id due missing permissions Resolve a permission issue when creating report periods with a user without admin rights. --- mis_builder/models/mis_report_instance.py | 8 +++++--- mis_builder/readme/newsfragments/596.bugfix | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 mis_builder/readme/newsfragments/596.bugfix diff --git a/mis_builder/models/mis_report_instance.py b/mis_builder/models/mis_report_instance.py index 95b4e46b9..f1577579c 100644 --- a/mis_builder/models/mis_report_instance.py +++ b/mis_builder/models/mis_report_instance.py @@ -322,9 +322,11 @@ def _compute_dates(self): def _check_source_aml_model_id(self): for record in self: if record.source_aml_model_id: - record_model = record.source_aml_model_id.field_id.filtered( - lambda r: r.name == "account_id" - ).relation + record_model = ( + record.source_aml_model_id.sudo() + .field_id.filtered(lambda r: r.name == "account_id") + .relation + ) report_account_model = record.report_id.account_model if record_model != report_account_model: raise ValidationError( diff --git a/mis_builder/readme/newsfragments/596.bugfix b/mis_builder/readme/newsfragments/596.bugfix new file mode 100644 index 000000000..868650ed5 --- /dev/null +++ b/mis_builder/readme/newsfragments/596.bugfix @@ -0,0 +1 @@ +Resolve a permission issue when creating report periods with a user without admin rights.