diff --git a/addons/account/static/src/components/account_move_form/account_move_form.js b/addons/account/static/src/components/account_move_form/account_move_form.js index b6c12f81881..e73fdef50dd 100644 --- a/addons/account/static/src/components/account_move_form/account_move_form.js +++ b/addons/account/static/src/components/account_move_form/account_move_form.js @@ -37,7 +37,7 @@ AccountMoveFormNotebook.props = { } export class AccountMoveFormRenderer extends FormRenderer { async saveBeforeTabChange() { - if (this.props.record.mode === "edit" && await this.props.record.isDirty()) { + if (this.props.record.isInEdition && await this.props.record.isDirty()) { const contentEl = document.querySelector('.o_content'); const scrollPos = contentEl.scrollTop; await this.props.record.save({ diff --git a/addons/account/static/tests/account_move_form_tests.js b/addons/account/static/tests/account_move_form_tests.js index 43273b55971..e40c7efac4a 100644 --- a/addons/account/static/tests/account_move_form_tests.js +++ b/addons/account/static/tests/account_move_form_tests.js @@ -1,8 +1,7 @@ /** @odoo-module **/ import { start, startServer } from "@mail/../tests/helpers/test_utils"; -import { patchWithCleanup } from "@web/../tests/helpers/utils"; -import { AccountMoveFormRenderer } from "@account/components/account_move_form/account_move_form"; +import { triggerHotkey } from "@web/../tests/helpers/utils"; import { accountMove as accountMoveService} from '@account/components/account_move_service/account_move_service'; QUnit.module("Views", {}, function (hooks) { @@ -17,22 +16,23 @@ QUnit.module("Views", {}, function (hooks) { `
- + + +
`, }; - const { click, openView } = await start({ + const { click, insertText, openView } = await start({ serverData: { views }, services: { 'account_move': accountMoveService, - } - }); - patchWithCleanup(AccountMoveFormRenderer.prototype, { - saveBeforeTabChange() { - super.saveBeforeTabChange(); - assert.step("tab saved"); + }, + async mockRPC(route) { + if (route === "/web/dataset/call_kw/account.move/write") { + assert.step("tab saved"); + } }, }); await openView({ @@ -40,8 +40,10 @@ QUnit.module("Views", {}, function (hooks) { res_model: 'account.move', views: [[false, 'form']], }); + await insertText("[name='name'] input", "somebody save me!"); + triggerHotkey("Enter") - click('a[name="aml_tab"]'); + await click('a[name="aml_tab"]'); assert.verifySteps(["tab saved"], "When clicking on a tab, the saving method should be called and succeed"); });