From b072e1bd5bb178da9dc0e8bd6a8b2bc7cbfe125c Mon Sep 17 00:00:00 2001 From: Lucas Perais Date: Fri, 30 Sep 2022 07:46:53 +0000 Subject: [PATCH] [FIX] web: form always edit: a virtual record can be discarded Before this commit, a virtual record in form view always had the o_form_dirty class, which is problematic when a tour ends with a virtual record. After this commit, a virtual non-dirty record in form view doesn't have the class o_form_dirty, and doesn't have the o_form_saved either as that doesn't make more sense. closes odoo/odoo#102153 X-original-commit: 0041b9fd8eb75d5b680d94d491e2b9f684b2d0c1 Related: odoo/enterprise#32282 Signed-off-by: Aaron Bohy (aab) --- .../static/src/views/form/form_compiler.js | 2 +- .../tests/views/form/form_compiler_tests.js | 10 +++--- .../tests/views/form/form_view_tests.js | 34 +++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/views/form/form_compiler.js b/addons/web/static/src/views/form/form_compiler.js index 6ecf88fad2e..eebcdba4b95 100644 --- a/addons/web/static/src/views/form/form_compiler.js +++ b/addons/web/static/src/views/form/form_compiler.js @@ -225,7 +225,7 @@ export class FormCompiler extends ViewCompiler { ? `d-flex {{ uiService.size < ${SIZES.XXL} ? "flex-column" : "flex-nowrap h-100" }}` : "d-block"; const stateClasses = - "{{ props.record.isVirtual or props.record.isDirty ? 'o_form_dirty' : 'o_form_saved' }}"; + "{{ props.record.isDirty ? 'o_form_dirty' : !props.record.isVirtual ? 'o_form_saved' : '' }}"; const form = createElement("div", { "t-att-class": "props.class", "t-attf-class": `{{props.record.isInEdition ? 'o_form_editable' : 'o_form_readonly'}} ${displayClasses} ${stateClasses}`, diff --git a/addons/web/static/tests/views/form/form_compiler_tests.js b/addons/web/static/tests/views/form/form_compiler_tests.js index e54c109a639..ee5fe8a603d 100644 --- a/addons/web/static/tests/views/form/form_compiler_tests.js +++ b/addons/web/static/tests/views/form/form_compiler_tests.js @@ -38,7 +38,7 @@ QUnit.module("Form Compiler", (hooks) => { const arch = /*xml*/ `
lol
`; const expected = /*xml*/ ` -
+
lol
`; @@ -52,7 +52,7 @@ QUnit.module("Form Compiler", (hooks) => { const arch = /*xml*/ `