This commit fixes a bug where the value of an autocomplete with autoselect could go into an undefined state where the model value doesn't match the input value but no change is detected. This would happen on escape press, scroll and more recently due to https://github.com/odoo/odoo/pull/159333 on click out. To fix this issue, the commit introduces some change in the autocomplete behavior so that it will no longer select the active option on click out (blur) when autoselect is active and instead it will revert the input value to the one stored into the model. Also applies this behavior on escape key press and scroll for the before mentioned reasons. Steps to reproduce: - Go to CRM form view - Edit the salesperson name to some non existant one and click out (or scroll or press escape) Before the fix, the name was stuck to the invalid one but no change was detected so we couldnt save it. Before https://github.com/odoo/odoo/pull/159333, click out would select the active option of the dropdown instead (and launch a dialog for quick create). This is removed because the behavior is neither intuitive nor practical. After the fix, the name is reset to its previous valid value instead. This applies to all autocomplete components with autoselect prop set to true. closes odoo/odoo#162040 X-original-commit: 9d9026ed0c7bb0af6cf910cc206cf8b55d1b7a36 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Julien Carion (juca) <juca@odoo.com>
77 lines
3.1 KiB
XML
77 lines
3.1 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<templates xml:space="preserve">
|
|
|
|
<t t-name="web.X2ManyFieldDialog">
|
|
<Dialog title="title" withBodyPadding="false" modalRef="modalRef" contentClass="contentClass">
|
|
<FormRenderer record="record" archInfo="archInfo"/>
|
|
<t t-set-slot="footer">
|
|
<t t-if="footerArchInfo">
|
|
<FormRenderer record="record" archInfo="footerArchInfo"/>
|
|
</t>
|
|
<t t-else="">
|
|
<t t-if="record.isInEdition">
|
|
<t t-if="canCreate">
|
|
<button class="btn btn-primary o_form_button_save" t-on-click="save" data-hotkey="c">Save & Close</button>
|
|
<button class="btn btn-primary o_form_button_save_new" t-on-click="saveAndNew" data-hotkey="n">Save & New</button>
|
|
</t>
|
|
<t t-else="">
|
|
<button class="btn btn-primary o_form_button_save" t-on-click="save" data-hotkey="c">Save</button>
|
|
</t>
|
|
<button class="btn btn-secondary o_form_button_cancel" t-on-click="discard" data-hotkey="j">Discard</button>
|
|
|
|
<t t-if="props.delete">
|
|
<button class="btn btn-secondary o_btn_remove" t-on-click="remove" data-hotkey="k">
|
|
<t t-if="props.deleteButtonLabel" t-out="props.deleteButtonLabel"/>
|
|
<t t-else="">Remove</t>
|
|
</button>
|
|
</t>
|
|
</t>
|
|
<t t-else="">
|
|
<button class="btn btn-primary o_form_button_cancel" t-on-click="() => this.props.close()" data-hotkey="j">Close</button>
|
|
</t>
|
|
</t>
|
|
</t>
|
|
</Dialog>
|
|
</t>
|
|
|
|
<t t-name="web.Many2XAutocomplete" >
|
|
<div class="o_input_dropdown" t-ref="autocomplete_container">
|
|
<input t-if="env.isSmall and props.dropdown"
|
|
type="text"
|
|
t-att-id="props.id"
|
|
class="o_input"
|
|
readonly=""
|
|
autocomplete="off"
|
|
t-att-placeholder="props.placeholder"
|
|
t-att-value="props.value"
|
|
t-on-click="onSearchMore"
|
|
t-on-barcode-search="onBarcodeSearch"
|
|
/>
|
|
<AutoComplete t-else=""
|
|
value="props.value"
|
|
id="props.id"
|
|
placeholder="props.placeholder"
|
|
sources="sources"
|
|
autoSelect="props.autoSelect"
|
|
onSelect.bind="onSelect"
|
|
onInput.bind="onInput"
|
|
onChange.bind="onChange"
|
|
dropdown="props.dropdown"
|
|
autofocus="props.autofocus"
|
|
resetOnSelect="props.value === ''"
|
|
onCancel.bind="onCancel"
|
|
/>
|
|
<span class="o_dropdown_button" />
|
|
</div>
|
|
</t>
|
|
|
|
<t t-name="web.AvatarMany2XAutocomplete">
|
|
<span class="o_avatar_many2x_autocomplete o_avatar d-flex align-items-center">
|
|
<img t-if="option.value" class="rounded me-1"
|
|
t-attf-src="/web/image/{{option.resModel}}/{{option.value}}/avatar_128" />
|
|
<t t-esc="option.label" />
|
|
</span>
|
|
</t>
|
|
|
|
</templates>
|