[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
This commit is contained in:
Vivek Pathak
2023-07-20 10:07:29 +02:00
parent cc6cf9ef13
commit 2c843fcb09
2 changed files with 3 additions and 47 deletions
@@ -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: () => {},
};
@@ -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: `
<form>
<sheet>
<group>
<field name="company_id"/>
<field name="display_name"/>
<field name="properties" widget="properties"/>
</group>
</sheet>
</form>`,
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");
}
);
});