From d0d2c2d9738f34f0b492bca09c955a733f50e37e Mon Sep 17 00:00:00 2001 From: "Pedram (PEBR)" Date: Wed, 20 Dec 2023 15:10:30 +0000 Subject: [PATCH] [FIX] point_of_sale: prevent order update when customer screen is open Previously, the order line quantity would inadvertently update if the Customer list screen was opened without clicking the search bar and typing numbers. This commit resolves the issue by disabling the event handler while a temp screen is open. Also, it enhances usability by focusing on the search bar upon opening the Customer list screen. opw-3634910 closes odoo/odoo#153506 X-original-commit: d792bb4b28c16b19452b7dcf06e73459ed9b8312 Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Pedram Bi Ria (pebr) --- .../static/src/app/screens/partner_list/partner_list.js | 3 ++- .../static/src/app/screens/product_screen/product_screen.js | 4 +++- addons/point_of_sale/static/src/app/store/pos_store.js | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js b/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js index 7fd5dd78d36..3451c525379 100644 --- a/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js +++ b/addons/point_of_sale/static/src/app/screens/partner_list/partner_list.js @@ -3,7 +3,7 @@ import { _t } from "@web/core/l10n/translation"; import { registry } from "@web/core/registry"; import { debounce } from "@web/core/utils/timing"; -import { useService } from "@web/core/utils/hooks"; +import { useService, useAutofocus } from "@web/core/utils/hooks"; import { useAsyncLockedMethod } from "@point_of_sale/app/utils/hooks"; import { session } from "@web/session"; @@ -37,6 +37,7 @@ export class PartnerListScreen extends Component { this.orm = useService("orm"); this.notification = useService("pos_notification"); this.searchWordInputRef = useRef("search-word-input-partner"); + useAutofocus({refName: 'search-word-input-partner'}); this.state = useState({ query: null, diff --git a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js index 38fe8467e76..5167103d1cd 100644 --- a/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js +++ b/addons/point_of_sale/static/src/app/screens/product_screen/product_screen.js @@ -61,7 +61,9 @@ export class ProductScreen extends ControlButtonsMixin(Component) { // the callbacks in `onMounted` hook. onMounted(() => this.numberBuffer.reset()); this.numberBuffer.use({ - triggerAtInput: (...args) => this.updateSelectedOrderline(...args), + triggerAtInput: (...args) => { + if (!this.pos.tempScreenIsShown) this.updateSelectedOrderline(...args); + }, useWithBarcode: true, }); } diff --git a/addons/point_of_sale/static/src/app/store/pos_store.js b/addons/point_of_sale/static/src/app/store/pos_store.js index d4d3204252b..fd54e2d94a6 100644 --- a/addons/point_of_sale/static/src/app/store/pos_store.js +++ b/addons/point_of_sale/static/src/app/store/pos_store.js @@ -151,6 +151,7 @@ export class PosStore extends Reactive { this.ordersToUpdateSet = new Set(); // used to know which orders need to be sent to the back end when syncing this.loadingOrderState = false; // used to prevent orders fetched to be put in the update set during the reactive change this.showOfflineWarning = true; // Allows to avoid the display of the offline popup when the user has already had it. + this.tempScreenIsShown = false; // these dynamic attributes can be watched for change by other models or widgets Object.assign(this, { @@ -1944,10 +1945,12 @@ export class PosStore extends Reactive { component: registry.category("pos_screens").get(name), props: { ...props, resolve }, }; + this.tempScreenIsShown = true; }); } closeTempScreen() { + this.tempScreenIsShown = false; this.tempScreen = null; } openCashControl() {