Skip to content

Commit 22e69f3

Browse files
committed
fix(cr): add nosemgrep comments to all sudo() calls
1 parent 1d72f06 commit 22e69f3

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

spp_change_request_v2/models/change_request.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def _compute_has_proposed_changes(self):
267267
try:
268268
# Use sudo to bypass record rules (e.g. global disabled-registrant
269269
# rules on spp.group.membership) — this is read-only preview logic.
270-
sudo_rec = rec.sudo()
270+
sudo_rec = rec.sudo() # nosemgrep: odoo-sudo-without-context
271271
strategy = sudo_rec.request_type_id.get_apply_strategy()
272272
changes = strategy.preview(sudo_rec) or {}
273273

@@ -715,7 +715,7 @@ def _ensure_detail(self):
715715

716716
# Use sudo() for creation - users don't need create permission
717717
# Detail records are always created by the system automatically
718-
detail = detail_model.sudo().create({cr_field: self.id})
718+
detail = detail_model.sudo().create({cr_field: self.id}) # nosemgrep: odoo-sudo-without-context
719719
self.detail_res_id = detail.id
720720

721721
# Pre-fill detail from registrant if the detail model supports it
@@ -885,7 +885,7 @@ def _generate_preview_html(self):
885885

886886
try:
887887
# Use sudo() so validators can preview memberships of disabled registrants
888-
sudo_self = self.sudo()
888+
sudo_self = self.sudo() # nosemgrep: odoo-sudo-without-context
889889
strategy = sudo_self.request_type_id.get_apply_strategy()
890890
changes = strategy.preview(sudo_self) or {}
891891
except Exception as e:
@@ -980,7 +980,7 @@ def _generate_review_comparison_html(self):
980980

981981
try:
982982
# Use sudo() so validators can preview memberships of disabled registrants
983-
sudo_self = self.sudo()
983+
sudo_self = self.sudo() # nosemgrep: odoo-sudo-without-context
984984
strategy = sudo_self.request_type_id.get_apply_strategy()
985985
changes = strategy.preview(sudo_self) or {}
986986
except Exception as e:
@@ -1092,7 +1092,7 @@ def _capture_preview_snapshot(self):
10921092
self.review_comparison_html_snapshot = self._generate_review_comparison_html()
10931093

10941094
# Also capture the JSON data (use sudo for record-rule bypass)
1095-
sudo_self = self.sudo()
1095+
sudo_self = self.sudo() # nosemgrep: odoo-sudo-without-context
10961096
strategy = sudo_self.request_type_id.get_apply_strategy()
10971097
changes = strategy.preview(sudo_self) or {}
10981098
self.preview_json_snapshot = json.dumps(changes, indent=2, default=str)
@@ -1136,7 +1136,7 @@ def _do_apply(self):
11361136
to (e.g. spp.group.membership blocked by global record rules).
11371137
"""
11381138
self.ensure_one()
1139-
sudo_self = self.sudo()
1139+
sudo_self = self.sudo() # nosemgrep: odoo-sudo-without-context
11401140
strategy = sudo_self.request_type_id.get_apply_strategy()
11411141
strategy.apply(sudo_self)
11421142

@@ -1248,7 +1248,7 @@ def _validate_documents(self):
12481248
def _create_log(self, action, notes=False):
12491249
"""Create a log entry for this change request."""
12501250
self.ensure_one()
1251-
self.env["spp.change.request.log"].sudo().create(
1251+
self.env["spp.change.request.log"].sudo().create( # nosemgrep: odoo-sudo-without-context
12521252
{
12531253
"change_request_id": self.id,
12541254
"action": action,
@@ -1274,7 +1274,7 @@ def _create_audit_event(self, action, old_state, new_state):
12741274
if not event_type:
12751275
return
12761276

1277-
self.env["spp.event.data"].sudo().create(
1277+
self.env["spp.event.data"].sudo().create( # nosemgrep: odoo-sudo-without-context
12781278
{
12791279
"event_type_id": event_type.id,
12801280
"partner_id": self.registrant_id.id,

0 commit comments

Comments
 (0)