[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) <jcb@odoo.com>
Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
Pedram (PEBR)
2024-02-12 10:44:45 +00:00
committed by Pedram (pebr)
parent 578b94ec26
commit d0d2c2d973
3 changed files with 8 additions and 2 deletions
@@ -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,
@@ -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,
});
}
@@ -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() {