[FIX] partner_autocomplete: fix quick creation issue

Before this commit auto complete suggestion were showing on partner field even though there
is no_create attribute on partner field and because of that user can create partner record
from that field even though user is not allow to create record from it and also it gives
trackback in partner portal field because of access_token.

This commit prevent auto complete suggestion when partner field has no_create attribute
set on them to avoid unnecessary partner creation from that field.

task-3690532

X-original-commit: ba2edab747db2c89d06feb9422d7f53a759766ae
Part-of: odoo/odoo#150279
This commit is contained in:
kcv-odoo
2024-01-20 09:33:38 +00:00
parent 8b8819c494
commit 6bbdd15817
2 changed files with 26 additions and 1 deletions
@@ -18,7 +18,12 @@ export class PartnerMany2XAutocomplete extends Many2XAutocomplete {
}
get sources() {
return super.sources.concat(
const sources = super.sources;
if (!this.props.quickCreate)
{
return sources;
}
return sources.concat(
{
options: async (request) => {
if (this.validateSearchTerm(request)) {
@@ -358,4 +358,24 @@ QUnit.module('partner_autocomplete', {
await triggerEvent(input, null, "blur");
assert.containsOnce(target, ".o_dialog");
});
QUnit.test("Hide auto complate suggestion for no create", async function (assert) {
const partnerMakeViewParams = {
...makeViewParams,
arch:
`<form>
<field name="company_type"/>
<field name="parent_id" widget="res_partner_many2one" options="{'no_create': True}"/>
</form>`
}
await makeView(partnerMakeViewParams);
const input = target.querySelector("[name='parent_id'] input");
await editInputNoChangeEvent(input, "blabla");
const autocompleteContainer = input.parentElement;
assert.containsNone(
autocompleteContainer,
".o-autocomplete--dropdown-item.partner_autocomplete_dropdown_many2one",
"There should be no option when partner field has no_create attribute"
);
});
});