From f833e7e0525367bc414b2d467020294643fa021f Mon Sep 17 00:00:00 2001 From: FrancoisGe Date: Mon, 6 Nov 2023 15:22:54 +0100 Subject: [PATCH] [FIX] web: x2m not editable inline with save & new Before this commit, in a form view with an x2many in non-editable list mode, creating a record by clicking on "Save&New" allows it to be edited inline despite the list view not being editable. The purpose of this commit is to prevent this from happening. How to reproduce: - Go to a form view with an x2many field in non-editable list mode - Add a record - Edit the new record - Click on Save&New - Edit the new record Before this commit: The new record is in edition in the list view After this commit The new record is not in edition in the list view Part-of: odoo/odoo#141269 --- addons/web/static/src/views/fields/relational_utils.js | 1 + addons/web/static/tests/views/fields/one2many_field_tests.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/fields/relational_utils.js b/addons/web/static/src/views/fields/relational_utils.js index 361a00372a5..268a9432653 100644 --- a/addons/web/static/src/views/fields/relational_utils.js +++ b/addons/web/static/src/views/fields/relational_utils.js @@ -587,6 +587,7 @@ export class X2ManyFieldDialog extends Component { if (await this.record.checkValidity({ displayNotification: true })) { await this.props.save(this.record); if (saveAndNew) { + await this.record.switchMode("readonly"); this.record = await this.props.addNew(); } } else { diff --git a/addons/web/static/tests/views/fields/one2many_field_tests.js b/addons/web/static/tests/views/fields/one2many_field_tests.js index 57a0400d7f4..9ab9c75b3e2 100644 --- a/addons/web/static/tests/views/fields/one2many_field_tests.js +++ b/addons/web/static/tests/views/fields/one2many_field_tests.js @@ -9846,7 +9846,7 @@ QUnit.module("Fields", (hooks) => {
- +