Skip to content

[20.0][MIG] web_remember_tree_column_width: Migration to 20.0 - #3751

Open
mcastillol14 wants to merge 30 commits into
OCA:20.0from
mcastillol14:20.0-mig-web_remember_tree_column_width
Open

mcastillol14 wants to merge 30 commits into
OCA:20.0from
mcastillol14:20.0-mig-web_remember_tree_column_width

Conversation

@mcastillol14

Copy link
Copy Markdown

Standard migration of web_remember_tree_column_width to 20.0, following the usual git format-patch/git am procedure to preserve commit history and authorship. Only change needed: manifest version bump to 20.0.1.0.0. No code changes (single JS asset, no Python, no tests).

frahikLV and others added 28 commits October 23, 2026 11:37
… widths

Remember the tree columns' widths across sessions, and after filtering, grouping, or reordering.
this fixes scss file not found error after installing the module
…on column

Fix an error when retrieving column sizes for lists containing one or more list_button columns.
This error occurs when a list_button column is placed between other columns in the list. This type of column is excluded from the querySelector string used to retrieve column headers, which can cause the index to shift and the column size to change when the list is displayed.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: web-17.0/web-17.0-web_remember_tree_column_width
Translate-URL: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_remember_tree_column_width/
Co-authored-by: Stefan Rijnhart <stefan@opener.amsterdam>
Fixes
```
Uncaught Javascript Error > Cannot read properties of undefined (reading 'isRTL')
```

when trying to resizing a column in a list view.

Caused by upstream change odoo/odoo#210559
Analogous to the inherited code, the event listener would work on the resize
stop event, but this event would regularly not have the same target as the
resize start event in which case the field name and size could not be
determined.
@OCA-git-bot OCA-git-bot added mod:web_remember_tree_column_width Module web_remember_tree_column_width series:20.0 labels Oct 23, 2026
@mcastillol14 mcastillol14 mentioned this pull request Oct 23, 2026
9 of 38 tasks

@BhaveshHeliconia BhaveshHeliconia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Functionally not working

Quotations.mp4

@mcastillol14

Copy link
Copy Markdown
Author

Thanks for testing this and recording the video, @BhaveshHeliconia — you were right, it was functionally broken.

I set up a real Odoo 20.0 instance (official odoo:20.0 image) and reproduced the bug with Playwright: the column width was saved to localStorage correctly on resize, but never restored after a page reload.

Root cause: the migration only bumped the version number but missed several real breaking changes in the OWL version shipped with 20.0 (signal-based reactivity):

  • tableRef is now a callable signal ref (tableRef()), not a classic Ref object (tableRef.el).
  • useMagicColumnWidths moved from a static class property to an instance property, so it must be read as renderer.useMagicColumnWidths instead of renderer.constructor.useMagicColumnWidths.
  • useComponent and useExternalListener no longer exist in owl; the component instance now has to be passed in explicitly, and useListener replaces useExternalListener.
  • setStoredColumnWidths also needed a guard for when the table ref isn't attached yet (effect runs once before mount), otherwise it throws Cannot read properties of null (reading 'querySelectorAll').

Just pushed a fix with all of the above. Verified against a real Odoo 20.0 container: resizing a column and reloading the page now keeps the new width, with no console errors.

Could you re-test when you have a chance?

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

Functionally working now, But squash the last commit into the migration commit.

@mcastillol14
mcastillol14 force-pushed the 20.0-mig-web_remember_tree_column_width branch from 125b1d8 to cb599b3 Compare October 26, 2026 09:18
@mcastillol14

Copy link
Copy Markdown
Author

Done, squashed the fix into the migration commit. Thanks for confirming it's working!

@XtremXpert XtremXpert 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.

Functional check on a Odoo 20.0 database (module installed, list view opened in a browser).

What I could verify:

  • the restore side works: I seeded odoo.columnWidth.resource.booking.type.name = 300 in localStorage, reloaded the list, and the name column renders at 300px (th.style.width = "300px"), with the other columns keeping their magic width;
  • the patch relies on ListRenderer.useMagicColumnWidths, which is still a truthy class property in 20.0 (list_renderer.js), so setStoredColumnWidths is actually called on mount and on window resize;
  • wrapping columnWidths.onStartResize does not break the upstream resize: the original handler only uses its closure variables, so calling it through the wrapper object is safe.

What I could not verify: the save side. The .o_resize handle has a zero-size bounding box, so a scripted pointer drag does not trigger onStartResize; I only checked that path by reading the code. Since the module is JS-only and has no test suite, a manual "resize a column, reload, width kept" by the reviewer would be worth it.

CI is green and the code follows the 20.0 column_width_hook API. Nothing blocking from my side.

@XtremXpert XtremXpert 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.

Functional validation complete on a Odoo 20.0 instance.

Both sides of the feature are now verified in a real browser:

  • save: resizing the "Name" column of a list view and reloading keeps the new width, and the value is stored under odoo.columnWidth.resource.booking.type.name in localStorage;
  • restore: a pre-seeded width (300) is applied on load (th.style.width = "300px"), including after a full reload.

Scope of the check: a plain list view. I did not exercise grouped lists or the export/optional-column cases.

CI is green and the code follows the 20.0 column_width_hook API (ListRenderer.useMagicColumnWidths is still a class property, and wrapping columnWidths.onStartResize does not break the upstream resize).

Approving from my side — thanks.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. Please update PR comment with the eventual changes and update commit message with Assisted-by trailer required by https://github.com/OCA/.github/blob/master/AI_POLICY.md

@StefanRijnhart

Copy link
Copy Markdown
Member

/ocabot migration web_remember_tree_column_width

@OCA-git-bot OCA-git-bot added this to the 20.0 milestone Nov 16, 2026

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh, there is a functional issue. See this video in which the opened menu shows my custom widths, and removing the filter resets to the standard widths:

output.webm

Claude suggests:

useEffect behaves differently in Odoo 20.0, so saved widths probably get overwritten (major)
list_renderer.esm.js uses useEffect(setStoredColumnWidths) from @odoo/owl.

  • Before: in Owl 2 (Odoo's frontend framework up to 19.0), useEffect with no dependencies ran after every mount and every re-render. Because the patch registers it after Odoo's own hook, the saved widths were applied after Odoo set its computed ones.
  • Now: in Owl 3, useEffect is a signal effect (owl.js:1728). It reruns only when a signal it reads changes, not after each render.
  • Effect: Odoo's column-width hook still recomputes widths on every render (onMounted/onPatched(forceColumnWidths) in column_width_hook.js:565) and writes its cached computed widths to the header cells each time. Those writes will usually win, so after
    filtering, grouping or any other re-render the saved widths are probably lost. That is exactly what the module is supposed to prevent. I haven't run it, so this is from reading the code; please check it in a browser.
  • Fix: Odoo's compatibility layer exists for this case (web/static/src/owl2/owl3_compatibility_layer.js:19): "replace all useEffect with useLayoutEffect". useLayoutEffect(setStoredColumnWidths) brings back the old run-after-every-render behaviour.

Another, unrelated suggestion:

A pointercancel event leaves the module's listener behind. In 20.0, Odoo's resize code also stops on pointercancel (column_width_hook.js:489, e.g. touch scrolling on a tablet). The module's own list still has only ["keydown", "pointerdown", "pointerup"]. After a cancelled resize, its window listener stays
attached. The next keydown or pointerup anywhere then calls preventDefault() and stopPropagation() on that event, which can swallow a key press, and saves a width. Fix: add "pointercancel" to the list.

@mcastillol14
mcastillol14 force-pushed the 20.0-mig-web_remember_tree_column_width branch from cb599b3 to a922700 Compare November 16, 2026 15:21
@oca-cla-bot

oca-cla-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@mcastillol14

Copy link
Copy Markdown
Author

Thanks for the detailed analysis and video, and for having your own Claude dig into the exact mechanism.

Applied your suggested fix (useEffect → useLayoutEffect, matching Odoo's own owl3_compatibility_layer.js guidance) plus the pointercancel addition, squashed into the migration commit.

Full transparency on verification: I set up a real Odoo 20.0 Docker instance (built 2026-11-02) and tried to reproduce the width-reset-on-filter-removal bug with several scenarios (plain filters, narrowing search, group by/ungroup, toggling row counts to force a scrollbar change) — in my environment the width survived all of them even with the unfixed code, so I couldn't directly confirm the regression before fixing it. That said, the root cause you (and your Claude) describe is real: I confirmed by reading owl.js directly that useEffect is implemented as onWillDestroy(effect(fn)) — a signal-tracked reactive effect, not a render-lifecycle hook — so whether it reruns after a given patch depends on exactly what reactive state getState()/tableRef() touch, which could easily differ between the Odoo 20.0 build you tested against and mine (it's still a moving nightly branch). The useLayoutEffect fix is strictly safer regardless (it's Odoo's own documented replacement for this exact case), and I confirmed it doesn't break the basic resize+reload flow.

Could you re-test with this commit on your end and confirm whether the filter-removal scenario from your video is now fixed?

@StefanRijnhart StefanRijnhart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed, thanks!

@mcastillol14

Copy link
Copy Markdown
Author

Done, picked it: 9211e6d

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

@mcastillol14 You need to cherry-pick that commit before your migration commit instead of adding it directly.

@mcastillol14
mcastillol14 force-pushed the 20.0-mig-web_remember_tree_column_width branch from 9211e6d to 8d44291 Compare November 18, 2026 14:40
@mcastillol14

Copy link
Copy Markdown
Author

You're right, fixed it — cherry-picked your original commit (400be12) preserving your authorship, with our migration commit rebased on top.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.