[FIX] partner_autocomplete: display autocomplete createEdit

Steps to reproduce:
[account, iap credit]
- create a new invoice
- start to write "test" for the partner

Issue:
The partner autocomplete is not displayed

Cause:
in #150106 we add a condition for the quickCreate bypassing the possibility of having createEdit set to true

opw-3698400

closes odoo/odoo#155781

X-original-commit: 5f342b816c16fbbaefdb61d8bfac8376132dbfeb
Signed-off-by: Louis Baudoux (lba) <lba@odoo.com>
Signed-off-by: Yolann Sabaux (yosa) <yosa@odoo.com>
This commit is contained in:
yosa-odoo
2024-02-29 08:58:00 +00:00
parent d7da674803
commit eabcf88f82
2 changed files with 36 additions and 2 deletions
@@ -19,7 +19,7 @@ export class PartnerMany2XAutocomplete extends Many2XAutocomplete {
get sources() {
const sources = super.sources;
if (!this.props.quickCreate)
if (!this.props.canCreate)
{
return sources;
}
@@ -67,7 +67,19 @@ export class PartnerMany2XAutocomplete extends Many2XAutocomplete {
}
export class PartnerAutoCompleteMany2one extends Many2OneField {}
PartnerMany2XAutocomplete.props = {
...Many2XAutocomplete.props,
canCreate: { type: Boolean, optional: true },
}
export class PartnerAutoCompleteMany2one extends Many2OneField {
get Many2XAutocompleteProps() {
return {
...super.Many2XAutocompleteProps,
canCreate: this.props.canCreate,
};
}
}
PartnerAutoCompleteMany2one.components = {
...Many2OneField.components,
@@ -378,4 +378,26 @@ QUnit.module('partner_autocomplete', {
"There should be no option when partner field has no_create attribute"
);
});
QUnit.test("Display auto complete suggestion for canCreate", async function (assert) {
assert.expect(1);
const partnerMakeViewParams = {
...makeViewParams,
arch:
`<form>
<field name="company_type"/>
<field name="parent_id" widget="res_partner_many2one" options="{'no_create': False}"/>
</form>`
}
await makeView(partnerMakeViewParams);
const input = target.querySelector("[name='parent_id'] input");
await editInputNoChangeEvent(input, "blabla");
const autocompleteContainer = input.parentElement;
assert.containsN(
autocompleteContainer,
".o-autocomplete--dropdown-item",
8,
"Clearbit and Odoo autocomplete options should be shown"
);
});
});