[FIX] web: Remove M2M tags avatars doesn't work on kanban Quick assigns

Steps to reproduce:

- Open a kanban view inside the project app
- Click on the "Quick Assign icon"
- Select a user A
- Directly unselect this user
- Close the dropdown and open the edited record
- you can see the user A is still assigned => bug

This bug was occurred by a missing awaiting promise inside the deleteTag
method.

closes odoo/odoo#129996

X-original-commit: b345af5389cd0cc3eb5e373d50ea62afc4e46b22
Signed-off-by: Francois Georis (fge) <fge@odoo.com>
Signed-off-by: Romain Estievenart (res) <res@odoo.com>
This commit is contained in:
Romain Estievenart
2023-07-28 16:29:21 +02:00
parent ee56ebd074
commit 79ed7b15c6
4 changed files with 48 additions and 8 deletions
@@ -22,9 +22,9 @@ export class AutosaveMany2ManyTagsField extends Many2ManyTagsField {
};
}
deleteTag(id) {
super.deleteTag(id);
this._saveOnUpdate();
async deleteTag(id) {
await super.deleteTag(id);
await this._saveOnUpdate();
}
willUpdateProps(nextProps) {
@@ -138,14 +138,14 @@ export class Many2ManyTagsField extends Component {
return !this.props.readonly;
}
deleteTag(id) {
async deleteTag(id) {
const tagRecord = this.props.record.data[this.props.name].records.find(
(record) => record.id === id
);
const ids = this.props.record.data[this.props.name].currentIds.filter(
(id) => id !== tagRecord.resId
);
this.props.record.data[this.props.name].replaceWith(ids);
await this.props.record.data[this.props.name].replaceWith(ids);
}
getDomain() {
@@ -67,9 +67,9 @@ export class Many2ManyTagsAvatarFieldPopover extends Many2ManyTagsAvatarField {
};
}
deleteTag(id) {
super.deleteTag(id);
this._saveUpdate();
async deleteTag(id) {
await super.deleteTag(id);
await this._saveUpdate();
}
async _saveUpdate() {
@@ -443,6 +443,46 @@ QUnit.module("Fields", (hooks) => {
);
});
QUnit.test(
"widget many2many_tags_avatar add/remove tags in kanban view",
async function (assert) {
assert.expect(3);
await makeView({
type: "kanban",
resModel: "turtle",
serverData,
arch: `
<kanban>
<templates>
<t t-name="kanban-box">
<div class="oe_kanban_global_click">
<field name="display_name"/>
<div class="oe_kanban_footer">
<div class="o_kanban_record_bottom">
<div class="oe_kanban_bottom_right">
<field name="partner_ids" widget="many2many_tags_avatar"/>
</div>
</div>
</div>
</div>
</t>
</templates>
</kanban>`,
async mockRPC(route, { method, args }) {
if (method === "write") {
assert.step(`write: ${args[1].partner_ids[0][2]}`);
}
},
});
await click(target, ".o_kanban_record:first-child .o_quick_assign", true);
// add and directly remove an item
await click(target, ".o_popover .o-autocomplete--dropdown-item:first-child");
await click(target, ".o_popover .o_tag .o_delete");
assert.verifySteps(["write: 1", "write: "]);
}
);
QUnit.test("widget many2many_tags_avatar delete tag", async function (assert) {
await makeView({
type: "form",