[FIX] web: SelectCreateDialog should set selection_mode for kanban

Steps to reproduce
==================

- Install purchase_stock
- Use a mobile viewport
- Go to Purchase
- Click on a record
- Try to set the "Deliver To" field
- Click on a record

-> An action is triggered and the record is not selected

Cause of the issue
==================

[commit] removed the only use of `forceGlobalClick`.

When it is set, KanbanRecord.selection_mode evaluates to true.

Solution
========

forceGlobalClick should be set when selecting a record from the
SelectCreateDialog.

[commit]: https://github.com/odoo/odoo/commit/6e18fb3c35281bdba26d9616150141298975bb40

opw-3337018

closes odoo/odoo#127632

X-original-commit: 7a1db9fade48d231a71084624fa0063989afd2b9
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
Hubert Van de Walle (huvw)
2023-07-06 20:56:11 +02:00
parent f9bf456ba9
commit cb5a1cfd16
2 changed files with 48 additions and 0 deletions
@@ -45,6 +45,8 @@ export class SelectCreateDialog extends Component {
};
if (type === "list") {
props.allowSelectors = this.props.multiSelect;
} else if (type === "kanban") {
props.forceGlobalClick = true;
}
return props;
}
@@ -102,4 +102,50 @@ QUnit.module("ViewDialogs", (hooks) => {
await click(target, ".o_form_button_save");
});
QUnit.test("SelectCreateDialog: selection_mode should be true", async function (assert) {
assert.expect(3);
serverData.views["product,false,kanban"] = `
<kanban>
<templates>
<t t-name="kanban-box">
<div class="o_primary" t-if="!selection_mode">
<a type="object" name="some_action">
<field name="name"/>
</a>
</div>
<div class="o_primary" t-if="selection_mode">
<field name="name"/>
</div>
</t>
</templates>
</kanban>`;
await makeView({
type: "form",
resModel: "sale_order_line",
serverData,
arch: `
<form>
<field name="product_id"/>
<field name="linked_sale_order_line" widget="many2many_tags"/>
</form>`,
async mockRPC(route, args) {
if (args.method === "create" && args.model === "sale_order_line") {
const { product_id: selectedId } = args.args[0];
assert.strictEqual(selectedId, 111, `the product should be selected`);
}
if (args.method === "some_action") {
assert.step("action should not be called");
}
},
});
await click(target, '.o_field_widget[name="product_id"] input');
await click(target, ".modal-dialog.modal-lg .o_kanban_record:nth-child(1) .o_primary span");
assert.containsNone(target, ".modal-dialog.modal-lg");
await click(target, ".o_form_button_save");
assert.verifySteps([]);
});
});