odoo/odoo#232156

Created by fw-bot
Merged at fda6e28a917be8ce4409d12431edfd91f8682db7

Statuses:

label
odoo-dev:18.0-17.0-fix-repair-order-focuscell-destroyed-471248-fw
head
a1d7cc10b9731cacce83d0bd130782ba97e63de4
merged
2 weeks ago by JavaScript, Aaron Bohy (aab)
odoo/odoo
17.0 #232097
18.0 #232156
saas-18.2 #234317

[FIX] web: Prevent focusCell() error on destroyed components

Steps to Reproduce:
- Open a Repair Order form view in Odoo 17 or 18.
- Navigate to the Parts tab.
- In the list view of parts, click the Smart Button on any part line.
- A pop-up form view opens showing detailed operations.
- Click the “Pick From” field value, but don't change its value.
- Click the Save button in the pop-up.
- Observe the browser console for the error: TypeError: Cannot read properties of null (reading 'querySelector') at ListRenderer.focusCell

Traceback:

TypeError: Cannot read properties of null (reading 'querySelector')
    at ListRenderer.focusCell (https://91307582-17-0-all.runbot219.odoo.com/web/assets/15b4f47/web.assets_web.min.js:9519:80)
    at ListRenderer.<anonymous> (https://91307582-17-0-all.runbot219.odoo.com/web/assets/15b4f47/web.assets_web.min.js:9477:272)

Root Cause:
- Asynchronous patching in OWL (onPatched with await Promise.resolve()) continues execution after the next tick, even if the component is destroyed.
- When the component is destroyed, OWL sets status(this) = 3 (DESTROYED).
- focusCell() accesses DOM using querySelector, which fails if the component is destroyed.
- The code did not check the component status before calling focusCell().

Fix:
- Added if (status(this) === destroyed) return; to stop focusCell() execution on destroyed components.
- Ensured async patching is handled safely with await Promise.resolve().
- Added onWillDestroy to clean up dialog callbacks, preventing memory leaks.

OPW - 5154694
PAD
Localhost issue reproduction steps

17:https://github.com/odoo/odoo/blob/f9726cfe93e8850a38d9de06acfa5d78473b50b0/addons/web/static/src/views/list/list_renderer.js#L223
18:https://github.com/odoo/odoo/blob/1cac54db8634267a780b4011291f1e8a80ac5f5b/addons/web/static/src/views/list/list_renderer.js#L213

Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #232097