[FIX] web: Many2One field don't show all records in small screen
Since the conversion in OWL of the `many2one_barcode` widget, on Mobile when we open the search more a filter value is added automatically in the filter and so when we want to change the value we need an additional step to remove the filter to see all records. This commit, use a 'custom event' to open the barcode search and restore the normal behaviour on the `click` event. Steps to reproduce: * Go to Timesheet * Add a new line * Select a project * Try to change the project => BUG show only the selected project closes odoo/odoo#106267 X-original-commit: 6d7f5a0abd79f6185831a2b9617b031d13da89be Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com> Signed-off-by: Romeo Fragomeli (rfr) <rfr@odoo.com> Co-authored-by: Romain Estievenart <res@odoo.com>
This commit is contained in:
co-authored by
Romain Estievenart
parent
a3d4d2dd7f
commit
d3ad21cdfc
@@ -232,7 +232,7 @@ export class Many2OneField extends Component {
|
||||
searchInput.value = barcode;
|
||||
searchInput.dispatchEvent(new Event("input"));
|
||||
if (this.env.isSmall) {
|
||||
searchInput.click();
|
||||
searchInput.dispatchEvent(new Event("barcode-search"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,14 @@ import { SelectCreateDialog } from "@web/views/view_dialogs/select_create_dialog
|
||||
* @property {Function | null} onDelete
|
||||
*/
|
||||
|
||||
import { Component, useComponent, useEffect, useEnv, useSubEnv, onWillUpdateProps } from "@odoo/owl";
|
||||
import {
|
||||
Component,
|
||||
useComponent,
|
||||
useEffect,
|
||||
useEnv,
|
||||
useSubEnv,
|
||||
onWillUpdateProps,
|
||||
} from "@odoo/owl";
|
||||
|
||||
//
|
||||
// Commons
|
||||
@@ -285,7 +292,7 @@ export class Many2XAutocomplete extends Component {
|
||||
return options;
|
||||
}
|
||||
|
||||
async onSearchMoreSmall() {
|
||||
async onBarcodeSearch() {
|
||||
const autoCompleteInput = this.autoCompleteContainer.el.querySelector("input");
|
||||
return this.onSearchMore(autoCompleteInput.value);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
readonly=""
|
||||
t-att-placeholder="props.placeholder"
|
||||
t-att-value="props.value"
|
||||
t-on-click="onSearchMoreSmall"
|
||||
t-on-click="onSearchMore"
|
||||
t-on-barcode-search="onBarcodeSearch"
|
||||
/>
|
||||
<AutoComplete t-else=""
|
||||
value="props.value"
|
||||
|
||||
@@ -154,4 +154,40 @@ QUnit.module("Fields", (hooks) => {
|
||||
await click(modal, ".o_kanban_record:nth-child(1)");
|
||||
await clickSave(target);
|
||||
});
|
||||
|
||||
QUnit.test("many2one with barcode show all records", async function (assert) {
|
||||
// The product selected (mock) for the barcode scanner
|
||||
const selectedRecordTest = serverData.models[PRODUCT_PRODUCT].records[0];
|
||||
|
||||
patchWithCleanup(BarcodeScanner, {
|
||||
scanBarcode: async () => selectedRecordTest.barcode,
|
||||
});
|
||||
|
||||
await makeView({
|
||||
type: "form",
|
||||
resModel: SALE_ORDER_LINE,
|
||||
serverData,
|
||||
arch: `
|
||||
<form>
|
||||
<field name="${PRODUCT_FIELD_NAME}" options="{'can_scan_barcode': True}"/>
|
||||
</form>`,
|
||||
mockRPC: barcodeMockRPC,
|
||||
});
|
||||
|
||||
// Select one product
|
||||
await click(target, ".o_barcode");
|
||||
|
||||
// Click on the input to show all records
|
||||
await click(target, ".o_input_dropdown > input");
|
||||
|
||||
const modal = target.querySelector(".modal-dialog.modal-lg");
|
||||
assert.containsOnce(target, modal, "there should be one modal opened in full screen");
|
||||
|
||||
assert.containsN(
|
||||
modal,
|
||||
".o_kanban_record .oe_kanban_global_click",
|
||||
3,
|
||||
"there should be 3 records displayed"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user