[FIX] partner_autocomplete: show confirmation dialog on blur

Make the res_partner_many2one behave similarly to the many2one field
during blur where a confirmation dialog is shown.

closes odoo/odoo#118008

Task-id: 3205625
X-original-commit: 198fdca401ff6b0062111f513138af76eeb68e23
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Joseph Caburnay
2023-04-11 18:49:27 +02:00
parent 6705c2f4fd
commit d7c12e6039
2 changed files with 14 additions and 2 deletions
@@ -38,7 +38,7 @@ export class PartnerMany2XAutocomplete extends Many2XAutocomplete {
);
}
async onSelect(option) {
async onSelect(option, params) {
if (option.partner_gid) { // Checks that it is a partner autocomplete option
const data = await this.partner_autocomplete.getCreateData(Object.getPrototypeOf(option));
let context = {
@@ -55,7 +55,7 @@ export class PartnerMany2XAutocomplete extends Many2XAutocomplete {
return this.openMany2X({ context });
}
else {
return super.onSelect(option);
return super.onSelect(option, params);
}
}
@@ -8,6 +8,7 @@ import {
getFixture,
patchWithCleanup,
triggerEvent,
editInput,
} from "@web/../tests/helpers/utils";
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
import { loadJS } from "@web/core/assets";
@@ -346,4 +347,15 @@ QUnit.module('partner_autocomplete', {
assert.strictEqual(target.querySelector(`[name=${fieldName}] input`).value, expectedValue, `${fieldName} should be filled`);
}
});
QUnit.test("Show confirmation dialog on input blur", async function (assert) {
assert.expect(1);
await makeView(makeViewParams);
const input = target.querySelector("[name=parent_id] input.o-autocomplete--input.o_input");
await triggerEvent(input, null, "focus");
await click(input);
await editInput(input, null, "go");
await triggerEvent(input, null, "blur");
assert.containsOnce(target, ".o_dialog");
});
});