Skip to content

feat: registry_admin_only_crud opt-out per action (#298)#302

Open
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:feat/298-registry-admin-crud-bypass
Open

feat: registry_admin_only_crud opt-out per action (#298)#302
Tarekchehahde wants to merge 1 commit into
OpenSPP:19.0from
Tarekchehahde:feat/298-registry-admin-crud-bypass

Conversation

@Tarekchehahde

Copy link
Copy Markdown

Summary

  • Skip registry CRUD restriction patches when action context includes bypass_registry_admin_only_crud: True.
  • Applies to both form and list controllers for res.partner.

Test plan

  • With spp_starter.registry_admin_only_crud enabled and non-admin user: default partner views remain read-only
  • Action with context={'bypass_registry_admin_only_crud': True}: New/save/edit available on that action only

Fixes #298

Made with Cursor

OpenSPP#298)

Honor bypass_registry_admin_only_crud on res.partner actions so one
view can allow non-admin create/edit while the global setting stays on.

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a bypassRegistryRestriction helper function to bypass registry restrictions on forms and lists when bypass_registry_admin_only_crud is enabled in the component's context. The review feedback highlights several opportunities to simplify the code by removing redundant !bypassRegistryRestriction(this) checks, as _registryRestricted is already falsy when bypassed. Additionally, it is recommended to combine two sequential if statements in the ListController setup into a single condition.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +165 to 170
if (
this._registryRestricted &&
!bypassRegistryRestriction(this)
) {
params.config.mode = "readonly";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since this._registryRestricted is already set to false when the restriction is bypassed, we don't need to check !bypassRegistryRestriction(this) here. We can revert this to the simpler original check.

        if (this._registryRestricted) {
            params.config.mode = "readonly";
        }

Comment on lines +177 to +181
if (
this._registryRestricted &&
REGISTRY_MODELS.includes(this.props.resModel) &&
!bypassRegistryRestriction(this)
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since this._registryRestricted is already set to false when the restriction is bypassed, we don't need to check !bypassRegistryRestriction(this) here. We can revert this to the simpler original check.

        if (this._registryRestricted && REGISTRY_MODELS.includes(this.props.resModel)) {

Comment on lines 201 to +206
if (!REGISTRY_MODELS.includes(modelName)) {
return;
}
if (bypassRegistryRestriction(this)) {
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

We can combine these two if statements into a single, cleaner condition.

Suggested change
if (!REGISTRY_MODELS.includes(modelName)) {
return;
}
if (bypassRegistryRestriction(this)) {
return;
}
if (!REGISTRY_MODELS.includes(modelName) || bypassRegistryRestriction(this)) {
return;
}

Comment on lines +269 to +273
if (
this._registryRestricted &&
REGISTRY_MODELS.includes(this.props.resModel) &&
!bypassRegistryRestriction(this)
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since we return early in setup() when bypassRegistryRestriction(this) is true, this._registryRestricted will remain undefined (falsy). Therefore, we don't need to check !bypassRegistryRestriction(this) here. We can revert this to the simpler original check.

        if (this._registryRestricted && REGISTRY_MODELS.includes(this.props.resModel)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spp_starter_sp_mis: make registry_admin_only_crud opt-out per action, not a global New-button hide

1 participant