feat: implement pin-based authorization for POS navigation, new order creation, and order restoration
This commit is contained in:
parent
1d3190cc5a
commit
c3e4eca9c6
28
static/src/app/components/navbar/navbar_patch.js
Normal file
28
static/src/app/components/navbar/navbar_patch.js
Normal file
@ -0,0 +1,28 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { Navbar } from "@point_of_sale/app/components/navbar/navbar";
|
||||
|
||||
patch(Navbar.prototype, {
|
||||
async onClickRegister() {
|
||||
const cashier = await this.pos._selectCashierByPin();
|
||||
if (!cashier) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pos.setCashier(cashier);
|
||||
|
||||
let order = this.pos.getOrder();
|
||||
if (!order) {
|
||||
order = this.pos.addNewOrder();
|
||||
}
|
||||
|
||||
if (order) {
|
||||
order.original_employee_id = cashier;
|
||||
order.employee_id = cashier;
|
||||
order.uiState.is_authorized = true;
|
||||
}
|
||||
|
||||
this.pos.navigateToOrderScreen(order);
|
||||
}
|
||||
});
|
||||
51
static/src/app/components/order_tabs/order_tabs_patch.js
Normal file
51
static/src/app/components/order_tabs/order_tabs_patch.js
Normal file
@ -0,0 +1,51 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { OrderTabs } from "@point_of_sale/app/components/order_tabs/order_tabs";
|
||||
|
||||
patch(OrderTabs.prototype, {
|
||||
async newFloatingOrder() {
|
||||
const cashier = await this.pos._selectCashierByPin();
|
||||
if (!cashier) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pos.setCashier(cashier);
|
||||
|
||||
const order = this.pos.addNewOrder();
|
||||
if (order) {
|
||||
order.original_employee_id = cashier;
|
||||
order.employee_id = cashier;
|
||||
order.uiState.is_authorized = true;
|
||||
}
|
||||
|
||||
this.pos.navigate("ProductScreen", {
|
||||
orderUuid: order.uuid,
|
||||
});
|
||||
|
||||
return order;
|
||||
},
|
||||
|
||||
async selectFloatingOrder(order) {
|
||||
const cashier = await this.pos._selectCashierByPin();
|
||||
if (!cashier) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pos.setCashier(cashier);
|
||||
|
||||
if (order) {
|
||||
if (!order.original_employee_id) {
|
||||
order.original_employee_id = order.employee_id || cashier;
|
||||
}
|
||||
order.uiState.is_authorized = true;
|
||||
}
|
||||
|
||||
this.pos.setOrder(order);
|
||||
const previousOrderScreen = order.getScreenData();
|
||||
this.pos.navigate(previousOrderScreen?.name || "ProductScreen", {
|
||||
orderUuid: order.uuid,
|
||||
});
|
||||
this.dialog.closeAll();
|
||||
}
|
||||
});
|
||||
@ -3,12 +3,14 @@ import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(OrderPaymentValidation.prototype, {
|
||||
async validateOrder(isForceValidate) {
|
||||
const originalEmployeeId = this.order.original_employee_id || this.order.employee_id;
|
||||
const originalEmployeeId = this.order?.original_employee_id || this.order?.employee_id;
|
||||
|
||||
await super.validateOrder(...arguments);
|
||||
const result = await super.validateOrder(...arguments);
|
||||
|
||||
if (originalEmployeeId) {
|
||||
if (originalEmployeeId && this.order) {
|
||||
this.order.employee_id = originalEmployeeId;
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user