Skip to content

Odoo Client Error: Cannot read properties of null (reading 'isDirty') When rapidly clicking through records in Bank Reconcile #806

@StanislavBerezovskii

Description

@StanislavBerezovskii

Image

Module

account_reconcile_oca

Describe the bug

[Problem:]
Given I click through the items in Bank Reconcile (Accounting > Reconcile)
When I keep clicking through the items on the list
Then I see Odoo Client Error Uncaught Promise > Cannot read properties of null (reading 'isDirty')
But it does NOT happen, when clicking thru the items slowly

To Reproduce

Affected versions:
getting the error on version 16.0.2.1.2 of the account_reconcile_oca addon

Steps to reproduce the behavior:

  1. Populate the account.reconcile menu. (or another that is affected by the reconcile_controller.esm.js)
  2. Rapidly click through the records in the menu (record panel on the left side)
  3. Error message Uncaught Promise > Cannot read properties of null (reading 'isDirty') will pop up

Expected behavior
The error pops up because the records are being loaded slower that the user clicks through them.
SO the expected behavior is simply no error message pop up when the records are being loaded normally.
I have found the solution myself and would like to suggest it here:

  1. Navigate to account_reconcile_oca\static\src\js\reconcile\reconcile_controller.esm.js
  2. Find the function async selectRecord(record)
  3. in the async selectRecord(record) function find the following code block:
        if (this.state.selectedRecordId && this.state.selectedRecordId !== resId) {
            if (this.form_controller && this.form_controller.model.root.isDirty) {
                await this.form_controller.model.root.save({
                    noReload: true,
                    stayInEdition: true,
                    useSaveErrorDialog: true,
                });
                await this.model.root.load();
                await this.render(true);
            }
        }
  1. Add an additional check to the if (this.form_controller && this.form_controller.model.root.isDirty) { line, like this:
    if (this.form_controller && this.form_controller.model.root && this.form_controller.model.root.isDirty) {
  2. This prevents the error pop up in the UI.

Thank you for your attention!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions