From 2c843fcb09c1aed298cb65ea9cc49128c03b2248 Mon Sep 17 00:00:00 2001 From: Vivek Pathak Date: Wed, 19 Jul 2023 06:43:04 +0000 Subject: [PATCH] [REV] web: prevent error on multiple property field deletions This commit reverts the changes from PR https://github.com/odoo/odoo/pull/126457. The previous changes aimed to fix the error that occurred when deleting the property field multiple times. However, the update behaviour now ensures that the property field popover closes after a single click on delete icon. Task-3371734 X-original-commit:https://github.com/odoo/odoo/commit/9dc7d596b07532aa021ee0ca0a2bcb3c2378caf1 X-original-commit: 9ae3e6e74b0fa52b392313510276b1cbfe5a2afd Part-of: odoo/odoo#129080 --- .../fields/properties/properties_field.js | 9 ++-- .../views/fields/properties_field_tests.js | 41 ------------------- 2 files changed, 3 insertions(+), 47 deletions(-) diff --git a/addons/web/static/src/views/fields/properties/properties_field.js b/addons/web/static/src/views/fields/properties/properties_field.js index e48829225dc..959e2175b5b 100644 --- a/addons/web/static/src/views/fields/properties/properties_field.js +++ b/addons/web/static/src/views/fields/properties/properties_field.js @@ -294,13 +294,10 @@ export class PropertiesField extends Component { confirm: () => { this.popover.close(); const propertiesDefinitions = this.propertiesList; - const foundPropertyDefinition = propertiesDefinitions.find( + propertiesDefinitions.find( (property) => property.name === propertyName - ); - if (foundPropertyDefinition) { - foundPropertyDefinition.definition_deleted = true; - this.props.record.update({ [this.props.name]: propertiesDefinitions }); - } + ).definition_deleted = true; + this.props.record.update({ [this.props.name]: propertiesDefinitions }); }, cancel: () => {}, }; diff --git a/addons/web/static/tests/views/fields/properties_field_tests.js b/addons/web/static/tests/views/fields/properties_field_tests.js index 8893e69836f..68c0ff4ad82 100644 --- a/addons/web/static/tests/views/fields/properties_field_tests.js +++ b/addons/web/static/tests/views/fields/properties_field_tests.js @@ -1772,45 +1772,4 @@ QUnit.module("Fields", (hooks) => { assert.ok(target.querySelector(".o_test_properties_not_empty")); } ); - - QUnit.test( - "properties: confirm the delete of an already deleted property does not throw an error", - async function (assert) { - async function mockRPC(route, { method, model, kwargs }) { - if (["check_access_rights", "check_access_rule"].includes(method)) { - return true; - } - } - await makeView({ - type: "form", - resModel: "partner", - resId: 3, - serverData, - arch: ` -
- - - - - - - -
`, - mockRPC, - }); - - // We open the property popover - await click(target, ".o_property_field:first-child .o_field_property_open_popover"); - - // We click on the delete button 2 times to get 2 confirmation popovers - await click(target, ".o_field_property_definition_delete"); - await click(target, ".o_field_property_definition_delete"); - - // We confirm both confirmation popovers - await click(target.querySelector(".modal-content .btn-primary")); - await click(target.querySelector(".modal-content .btn-primary")); - - assert.containsNone(target, ".modal-content"); - } - ); });