Skip to content

Bug: CEL Expressions tab crashes and hidden menus reset on upgrade#166

Merged
kneckinator merged 5 commits into
19.0from
fix/cel-codeeditor-mode
Jun 4, 2026
Merged

Bug: CEL Expressions tab crashes and hidden menus reset on upgrade#166
kneckinator merged 5 commits into
19.0from
fix/cel-codeeditor-mode

Conversation

@haklyray
Copy link
Copy Markdown
Contributor

@haklyray haklyray commented Apr 22, 2026

1. CodeEditor crash on Approval Definition CEL Expressions tab

Steps to reproduce:

  1. Go to Approvals > Configuration > Approval Definitions
  2. Open any approval definition
  3. Click the "CEL Expressions" tab
  4. Tick "Use CEL Condition" (or "Use CEL for Reviewers") — this step is required. The ace editor field is invisible="not use_cel_condition" (and use_cel_* defaults to False), so the CodeEditor component only mounts once the toggle is enabled. Opening the tab alone does not crash, which is why the issue could not be reproduced from the steps as originally written.

Expected: The CEL expression editor renders normally
Actual: JS crash: Invalid props for component 'CodeEditor': 'mode' is not valid

Root cause: spp_approval/views/approval_definition_views_cel.xml uses options="{'mode': 'text'}" on widget="ace" fields. Odoo 19's CodeEditor component only accepts modes: javascript, xml, qweb, scss, python. text is not a valid mode.

2. Hidden menus become visible after module upgrade

Steps to reproduce:

  1. Hide a menu via spp_hide_menus_base (e.g. Discuss, Contacts)
  2. Upgrade any module that defines that menu
  3. The menu reappears despite being marked as hidden

Root cause: Module upgrade re-applies menu XML data (noupdate="0"), resetting group_ids. The hide_menus() hook in ir.module.module.next() skips menus with state="hide", so the reset is never corrected.

Copy link
Copy Markdown

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

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 modifies the ace widget configuration for CEL fields to use python mode and adds logic to re-apply menu hiding settings during module upgrades. The reviewer recommends using javascript mode instead of python for CEL expressions to ensure correct syntax highlighting, as CEL's syntax aligns more closely with JavaScript.

Comment thread spp_approval/views/approval_definition_views_cel.xml Outdated
Comment thread spp_approval/views/approval_definition_views_cel.xml Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.06%. Comparing base (1460aa5) to head (ffd42c5).
⚠️ Report is 6 commits behind head on 19.0.

Files with missing lines Patch % Lines
spp_hide_menus_base/models/hide_menu.py 77.77% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             19.0     #166   +/-   ##
=======================================
  Coverage   73.06%   73.06%           
=======================================
  Files        1069     1069           
  Lines       62105    62120   +15     
=======================================
+ Hits        45377    45390   +13     
- Misses      16728    16730    +2     
Flag Coverage Δ
spp_analytics 93.13% <ø> (ø)
spp_api_v2 80.33% <ø> (ø)
spp_api_v2_change_request 66.85% <ø> (ø)
spp_api_v2_cycles 71.12% <ø> (ø)
spp_api_v2_data 64.41% <ø> (ø)
spp_api_v2_entitlements 70.19% <ø> (ø)
spp_api_v2_gis 71.52% <ø> (ø)
spp_api_v2_products 66.27% <ø> (ø)
spp_api_v2_service_points 70.94% <ø> (ø)
spp_api_v2_simulation 71.12% <ø> (ø)
spp_api_v2_vocabulary 57.26% <ø> (ø)
spp_approval 50.29% <ø> (ø)
spp_area 80.07% <ø> (ø)
spp_area_hdx 81.43% <ø> (ø)
spp_audit 72.60% <ø> (ø)
spp_base_common 90.26% <ø> (ø)
spp_hide_menus_base 87.83% <86.66%> (-0.30%) ⬇️
spp_programs 64.84% <ø> (ø)
spp_registry 86.83% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_approval/__manifest__.py 0.00% <ø> (ø)
spp_hide_menus_base/__manifest__.py 0.00% <ø> (ø)
spp_hide_menus_base/models/ir_module_module.py 90.32% <100.00%> (+2.32%) ⬆️
spp_hide_menus_base/models/hide_menu.py 87.17% <77.77%> (-2.83%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anthonymarkQA
Copy link
Copy Markdown
Contributor

anthonymarkQA commented Apr 23, 2026

Findings: Returned to dev

Kindly check @gonzalesedwin1123

  1. CodeEditor crash on Approval Definition CEL Expressions tab -
    Unable to replicate issue from branch 19.0 therefore i cannot tell if fix was applied in this branch
    tested in both 19.0 and fix/cel-codeeditor-mode

  2. Hidden menus become visible after module upgrade -
    issue still exists, upgrading contacts module reappears in the menu after upgrading despite it being hidden by default.
    tested in fix/cel-codeeditor-mode

@kneckinator kneckinator self-assigned this Jun 4, 2026
1. spp_approval: change ace widget mode from 'text' to 'python' in
   CEL expression fields. Odoo 19 CodeEditor only accepts
   javascript/xml/qweb/scss/python — 'text' crashes with
   "Invalid props for component 'CodeEditor': 'mode' is not valid".

2. spp_hide_menus_base: re-apply hiding when module upgrade resets
   menu group_ids via XML (noupdate="0"). Previously, menus with
   state="hide" were skipped in hide_menus(), so an upgrade that
   re-applied the original group_ids left them visible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kneckinator
Copy link
Copy Markdown
Contributor

@anthonymarkQA the "Steps to reproduce were incomplete" which is why you couldn't reproduce it. I will update the steps and also add automated unit tests to validate this so it doesn't regress.

@kneckinator kneckinator self-requested a review June 4, 2026 09:55
@kneckinator
Copy link
Copy Markdown
Contributor

@anthonymarkQA — I've updated the PR description with corrected reproduction steps for issue #1.

The original steps were incomplete, which is why you couldn't replicate the CEL crash: the ace editor field is invisible="not use_cel_condition" and the use_cel_* toggles default to False, so the CodeEditor component never mounts (and never crashes) until you enable the toggle. Just opening the "CEL Expressions" tab is not enough.

To reproduce on 19.0: open an approval definition → "CEL Expressions" tab → tick "Use CEL Condition" (or "Use CEL for Reviewers") → the editor mounts and throws Invalid props for component 'CodeEditor': 'mode' is not valid. With this branch, it renders fine.

For issue #2 (hidden menus on upgrade): please note which upgrade path you used when you saw it reappear (the inline Apps "Upgrade" button vs. the upgrade-confirmation wizard vs. CLI -u). The re-hide only fires via ir.module.module.next(), which the wizard and CLI paths don't call — so that gap may explain what you saw, and it's worth confirming against the exact path.

Add a guardrail asserting the CEL Expressions view's ace fields use a
CodeEditor-valid mode (regression test for the 'text' mode crash that
broke the tab), plus unit and integration coverage for
spp_hide_menus_base._reapply_hide() and the hide_menus() re-hide branch
that runs after a module upgrade resets a menu's group_ids.
@kneckinator kneckinator force-pushed the fix/cel-codeeditor-mode branch from 73c8be5 to 821aabd Compare June 4, 2026 10:51
…ister_hook

next() only fires on the immediate install/upgrade path
(button_immediate_*). Upgrades through the base.module.upgrade wizard or
the CLI (-u) reload menu XML (noupdate="0"), resetting group_ids, but
never call next() — so hidden menus reappeared after those upgrades.
_register_hook runs at the end of every registry load (startup, install,
upgrade — all paths), re-applying hiding regardless of how the upgrade
was triggered.
@anthonymarkQA
Copy link
Copy Markdown
Contributor

anthonymarkQA commented Jun 4, 2026

Findings: QA passed

Issue 1:
exact steps to replicate for reference

  1. in branch 19.0, start spp with preinstalled module ./spp start --demo mis start
  2. Open the new instance in a private browser to eliminate cache issues
  3. Login as admin and activate dev mode
  4. Go to approvals > Configuration > Approval definition > Select any approval definition > tick "Use CEL Condition" (or "Use CEL for Reviewers")
  5. Notice the error will appear, this issue has been verified working in branch fix/cel-codeeditor-mode.

Issue 2:
exact steps to replicate for reference

  1. start openspp, ./spp restart --demo mis start
  2. login as admin and hide manually the unwanted components in openspp, contacts, inventory, etc.. via Activate developer mode >Settings>Users and companies>Hidden menus
  3. Update any module via CLI ./spp update spp_api_v2
  4. Open the new instance in a private browser to eliminate cache issues
  5. Notice the hidden menus reappear after CLI update. this issue has been verified working in branch fix/cel-codeeditor-mode.
  6. FYI, for this issue#2, I also tested against branch fix/cel-codeeditor-mode updating a module via Grid view or list view in the GUI and it works as expected.

@gonzalesedwin1123 @kneckinator feel free to merge if test steps are correct or sufficient enough.

@kneckinator
Copy link
Copy Markdown
Contributor

Thanks for the quick review @anthonymarkQA 🙏

Version bump so existing installs pick up the fixes on upgrade. The
spp_approval bump is functional: the CEL view fix is an ir.ui.view (XML)
change that only re-applies when the module version increases. Add
matching HISTORY.md entries.
CEL uses JS-family syntax (&&, ||, !, true/false/null and ? : ternaries),
so 'javascript' highlights expressions correctly where 'python' would
flag them as errors. Cosmetic only — both are valid CodeEditor modes.
Addresses the Gemini review comment on PR #166. Also regenerates the
README/index artifacts from the updated HISTORY fragments for both
modules.
@kneckinator
Copy link
Copy Markdown
Contributor

Re: @gemini-code-assist's suggestion to use javascript instead of python for the CEL ace fields — good catch, applied in ffd42c5.

Confirmed against the parser (spp_cel_domain/services/cel_parser.py): this CEL dialect is JS-family, not Python — it uses && / || / !, true / false / null, and ? : ternaries (e.g. the view's own example record.total > 5000 || record.priority == "high"). python mode would mis-highlight exactly those constructs; javascript highlights them correctly. It's cosmetic only (mode affects highlighting, not validation, which is server-side), and both are valid CodeEditor.MODES, so this isn't a correctness change — just better DX.

@kneckinator kneckinator merged commit e9dad7e into 19.0 Jun 4, 2026
35 checks passed
@kneckinator kneckinator deleted the fix/cel-codeeditor-mode branch June 4, 2026 16:36
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.

4 participants