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"); - } - ); });