mirror of
https://github.com/bringout/oca-ocb-pos.git
synced 2026-04-23 18:42:02 +02:00
19.0 vanilla
This commit is contained in:
parent
6e54c1af6c
commit
3ca647e428
1087 changed files with 132065 additions and 108499 deletions
|
|
@ -1,5 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="2000" height="1128" viewBox="0 0 2000 1128">
|
||||
<polygon fill-opacity=".03" points="0 1077.844 392.627 778.443 1504.99 1127.745 0 1127.745"/>
|
||||
<polygon fill-opacity=".02" points="392.216 778.443 283.294 0 0 0 0 666.504"/>
|
||||
<polygon fill-opacity=".03" points="1000 0 2000 1009.98 2000 439.94 1749.817 0"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 366 B |
|
|
@ -0,0 +1,9 @@
|
|||
import { Chrome } from "@point_of_sale/app/pos_app";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(Chrome.prototype, {
|
||||
get showCashMoveButton() {
|
||||
const { cashier } = this.pos;
|
||||
return super.showCashMoveButton && (!cashier || cashier._role == "manager");
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import { CashierName } from "@point_of_sale/app/components/navbar/cashier_name/cashier_name";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { useCashierSelector } from "@pos_hr/app/utils/select_cashier_mixin";
|
||||
|
||||
patch(CashierName.prototype, {
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
this.cashierSelector = useCashierSelector();
|
||||
}
|
||||
},
|
||||
//@Override
|
||||
get avatar() {
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
const cashier = this.pos.getCashier();
|
||||
if (!(cashier && cashier.id)) {
|
||||
return "";
|
||||
}
|
||||
return `/web/image/hr.employee.public/${cashier.id}/avatar_128`;
|
||||
}
|
||||
return super.avatar;
|
||||
},
|
||||
//@Override
|
||||
get cssClass() {
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
return { oe_status: true };
|
||||
}
|
||||
return super.cssClass;
|
||||
},
|
||||
async selectCashier(pin = false, login = false, list = false) {
|
||||
return await this.cashierSelector(...arguments);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="pos_hr.CashierName" t-inherit="point_of_sale.CashierName" t-inherit-mode="extension">
|
||||
<xpath expr="//button" position="attributes">
|
||||
<attribute name="t-on-click">() => this.selectCashier(false, true, true)</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { Navbar } from "@point_of_sale/app/components/navbar/navbar";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(Navbar.prototype, {
|
||||
get showCreateProductButton() {
|
||||
if (!this.pos.config.module_pos_hr || this.pos.employeeIsAdmin) {
|
||||
return super.showCreateProductButton;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
get showBackend() {
|
||||
const cashier = this.pos.getCashierUserId();
|
||||
return !this.pos.config.module_pos_hr || (cashier && cashier.id === this.pos.user?.id);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="pos_hr.Navbar" t-inherit="point_of_sale.Navbar" t-inherit-mode="extension">
|
||||
<xpath expr="//DropdownItem[contains(text(), 'Backend')]" position="attributes">
|
||||
<attribute name="t-if">showBackend</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//DropdownItem[contains(text(), 'Close Register')]" position="attributes">
|
||||
<attribute name="t-if">
|
||||
!pos.config.module_pos_hr or pos.employeeIsAdmin or pos.getCashierUserId() === pos.session.user_id?.id
|
||||
</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//CashierName" position="after">
|
||||
<button t-if="pos.config.module_pos_hr and !ui.isSmall" class="lock-screen btn btn-light btn-lg" title="Lock" t-on-click="() => this.pos.showLoginScreen()">
|
||||
<i class="fa fa-fw fa-unlock"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr="//Dropdown//div[hasclass('pos-burger-menu-items')]" position="inside">
|
||||
<DropdownItem t-if="pos.config.module_pos_hr and ui.isSmall" onSelected="() => this.pos.showLoginScreen()">
|
||||
Lock
|
||||
</DropdownItem>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import { CashMovePopup } from "@point_of_sale/app/components/popups/cash_move_popup/cash_move_popup";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(CashMovePopup.prototype, {
|
||||
_prepareTryCashInOutPayload() {
|
||||
const result = super._prepareTryCashInOutPayload(...arguments);
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
const employee_id = this.pos.getCashier().id;
|
||||
result[result.length - 1] = { ...result[result.length - 1], employee_id };
|
||||
}
|
||||
return result;
|
||||
},
|
||||
get partnerId() {
|
||||
return this.pos.config.module_pos_hr
|
||||
? this.pos.cashier.work_contact_id?.id
|
||||
: super.partnerId;
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { Component } from "@odoo/owl";
|
||||
import { Dialog } from "@web/core/dialog/dialog";
|
||||
import { usePos } from "@point_of_sale/app/hooks/pos_hook";
|
||||
export class CashierSelectionPopup extends Component {
|
||||
static template = "pos_hr.CashierSelectionPopup";
|
||||
static components = { Dialog };
|
||||
static props = {
|
||||
close: Function,
|
||||
getPayload: Function,
|
||||
currentCashier: { type: Object, optional: true },
|
||||
employees: { type: Array },
|
||||
};
|
||||
|
||||
setup() {
|
||||
this.pos = usePos();
|
||||
}
|
||||
|
||||
async lock() {
|
||||
await this.pos.showLoginScreen();
|
||||
}
|
||||
selectEmployee(employee) {
|
||||
this.props.getPayload(employee);
|
||||
this.props.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="pos_hr.CashierSelectionPopup">
|
||||
<Dialog title.translate="Select Cashier" footer="false" size="'md'" bodyClass="'d-flex flex-column gap-2'">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center btn btn-outline-secondary active p-2 p-sm-3 border-transparent cursor-default text-start"
|
||||
t-on-click="() => this.props.close()" t-if="props.currentCashier">
|
||||
<t t-set="cashier" t-value="props.currentCashier"/>
|
||||
<div class="d-flex align-items-center ">
|
||||
<div class="ratio ratio-1x1 me-2 me-sm-3" style="width: 40px">
|
||||
<img class="rounded-3" t-attf-src="/web/image/hr.employee.public/{{cashier.id}}/avatar_128"/>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="fs-4 fw-bold current-cashier-name" t-out="cashier.name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center ms-1">
|
||||
<button class="btn-cashier-lock btn btn-lg btn-secondary" title="Lock" t-on-click.stop="() => this.lock()">
|
||||
<i class="fa fa-fw fa-lock"/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button t-foreach="props.employees" t-as="employee" t-key="employee.id"
|
||||
class="selection-item d-flex align-items-center justify-content-between btn btn-outline-secondary p-2 p-sm-3 text-start"
|
||||
t-on-click="() => this.selectEmployee(employee)">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="ratio ratio-1x1 me-2 me-sm-3" style="width: 40px">
|
||||
<img class="rounded-3" t-attf-src="/web/image/hr.employee.public/{{employee.id}}/avatar_128"/>
|
||||
</div>
|
||||
<div class="d-flex flex-column">
|
||||
<span class="fs-4 fw-bold" t-out="employee.name"/>
|
||||
</div>
|
||||
</div>
|
||||
<i class="oi oi-chevron-right"/>
|
||||
</button>
|
||||
|
||||
</Dialog>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
import { ClosePosPopup } from "@point_of_sale/app/components/popups/closing_popup/closing_popup";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(ClosePosPopup.prototype, {
|
||||
hasUserAuthority() {
|
||||
if (!this.pos.config.module_pos_hr) {
|
||||
return super.hasUserAuthority();
|
||||
}
|
||||
const cashier = this.pos.cashier;
|
||||
return (
|
||||
(cashier._role == "manager" && cashier._user_role == "admin") ||
|
||||
this.allowedDifference()
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="pos_hr.ClosePosPopup" t-inherit="point_of_sale.ClosePosPopup" t-inherit-mode="extension">
|
||||
<xpath expr="//div[hasclass('payment-methods-overview')]" position="attributes">
|
||||
<attribute name="t-if">!pos.config.module_pos_hr</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('payment-methods-overview')]" position="after">
|
||||
<t t-if="pos.config.module_pos_hr">
|
||||
<div t-if="pos.config.cash_control and pos.config.module_pos_hr" class="w-100 mb-3">
|
||||
<t t-set="diff" t-value="getDifference(props.default_cash_details.id)" />
|
||||
<t t-set="counted" t-value="state.payments[props.default_cash_details.id]?.counted || '0'" />
|
||||
<div class="d-flex align-items-center justify-content-between fs-3">
|
||||
<span t-esc="props.default_cash_details.name" />
|
||||
<span t-esc="env.utils.formatCurrency(props.default_cash_details.amount)" />
|
||||
</div>
|
||||
<div class="d-flex align-items-center justify-content-between text-muted border-start ps-2">
|
||||
<span>Opening</span>
|
||||
<span t-esc="env.utils.formatCurrency(props.default_cash_details.opening)" />
|
||||
</div>
|
||||
<t t-set="amountByEmployee" t-value="props.default_cash_details.amount_per_employee" />
|
||||
<PaymentMethodBreakdown title.translate="Payments" total_amount="props.default_cash_details.payment_amount" transactions="props.default_cash_details.amount_per_employee"/>
|
||||
<PaymentMethodBreakdown title.translate="Cash in/out" total_amount="getMovesTotalAmount()" transactions="props.default_cash_details.moves_per_employee"/>
|
||||
<div class="d-flex align-items-center justify-content-between text-muted border-start ps-2">
|
||||
<span>Counted</span>
|
||||
<span t-esc="env.utils.formatCurrency(env.utils.parseValidFloat(counted))" />
|
||||
</div>
|
||||
<div class="d-flex align-items-center justify-content-between text-muted border-start ps-2" t-att-class="{'text-danger fw-bold': diff}">
|
||||
<span>Difference</span>
|
||||
<span class="cash-difference" t-esc="env.utils.formatCurrency(diff)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-100 mb-3" t-foreach="props.non_cash_payment_methods" t-as="pm" t-key="pm.id">
|
||||
<t t-set="_showDiff" t-value="pm.type === 'bank' and pm.number !== 0" />
|
||||
<t t-set="diff" t-value="_showDiff ? getDifference(pm.id) : 0" />
|
||||
<t t-set="counted" t-value="_showDiff ? env.utils.parseValidFloat(state.payments[pm.id].counted) : 0" />
|
||||
<div class="d-flex align-items-center justify-content-between fs-3">
|
||||
<span t-esc="pm.name" />
|
||||
<span t-esc="env.utils.formatCurrency(pm.amount)" />
|
||||
</div>
|
||||
<PaymentMethodBreakdown title.translate="Payments" total_amount="pm.amount" transactions="pm.amount_per_employee"/>
|
||||
<div class="d-flex align-items-center justify-content-between text-muted border-start ps-2" t-att-class="{'text-danger fw-bold': diff}">
|
||||
<span>Difference</span>
|
||||
<span t-esc="env.utils.formatCurrency(diff)" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { ProductInfoPopup } from "@point_of_sale/app/components/popups/product_info_popup/product_info_popup";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(ProductInfoPopup.prototype, {
|
||||
get allowProductEdition() {
|
||||
return !this.pos.config.module_pos_hr || this.pos.employeeIsAdmin;
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { DataServiceOptions } from "@point_of_sale/app/models/data_service_options";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(DataServiceOptions.prototype, {
|
||||
get uniqueModels() {
|
||||
return [...super.uniqueModels, "hr.employee"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import { PosOrder } from "@point_of_sale/app/models/pos_order";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(PosOrder.prototype, {
|
||||
// @Override
|
||||
getCashierName() {
|
||||
return this.employee_id?.name?.split(" ").at(0) || super.getCashierName(...arguments);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import { useCashierSelector } from "@pos_hr/app/utils/select_cashier_mixin";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { LoginScreen } from "@point_of_sale/app/screens/login_screen/login_screen";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
import { useAutofocus } from "@web/core/utils/hooks";
|
||||
import { onWillUnmount, useExternalListener, useState } from "@odoo/owl";
|
||||
|
||||
patch(LoginScreen.prototype, {
|
||||
setup() {
|
||||
super.setup(...arguments);
|
||||
|
||||
this.state = useState({
|
||||
pin: "",
|
||||
});
|
||||
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
this.cashierSelector = useCashierSelector({
|
||||
onScan: (employee) => employee && this.selectOneCashier(employee),
|
||||
exclusive: true,
|
||||
});
|
||||
|
||||
useAutofocus();
|
||||
useExternalListener(window, "keypress", async (ev) => {
|
||||
if (this.pos.login && ev.key === "Enter" && this.state.pin) {
|
||||
await this.selectCashier(this.state.pin, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onWillUnmount(() => {
|
||||
this.state.pin = "";
|
||||
this.pos.login = false;
|
||||
});
|
||||
},
|
||||
async selectCashier(pin = false, login = false, list = false) {
|
||||
return await this.cashierSelector(pin, login, list);
|
||||
},
|
||||
openRegister() {
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
this.pos.login = true;
|
||||
} else {
|
||||
super.openRegister();
|
||||
}
|
||||
},
|
||||
async clickBack() {
|
||||
if (!this.pos.config.module_pos_hr) {
|
||||
super.clickBack();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.pos.login) {
|
||||
this.state.pin = "";
|
||||
this.pos.login = false;
|
||||
} else {
|
||||
const employee = await this.selectCashier();
|
||||
if (employee && employee.user_id?.id === this.pos.user.id) {
|
||||
super.clickBack();
|
||||
return;
|
||||
} else if (employee) {
|
||||
this.pos.notification.add(
|
||||
_t(
|
||||
"Only the cashier linked to the logged-in user (%s) can proceed to the Backend.",
|
||||
this.pos.user.name
|
||||
),
|
||||
{ type: "danger" }
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
get backBtnName() {
|
||||
return this.pos.login && this.pos.config.module_pos_hr ? _t("Discard") : super.backBtnName;
|
||||
},
|
||||
maskedInput(ev) {
|
||||
ev.preventDefault();
|
||||
const input = ev.target;
|
||||
const pin = this.state.pin || "";
|
||||
const maskedLen = input.value.length;
|
||||
this.state.pin = maskedLen < pin.length ? pin.slice(0, maskedLen) : pin + (ev.data || "");
|
||||
|
||||
input.value = "•".repeat(this.state.pin.length);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="pos_hr.LoginScreen" t-inherit="point_of_sale.LoginScreen" t-inherit-mode="extension">
|
||||
<xpath expr="//div[hasclass('screen-login')]" position="attributes">
|
||||
<attribute name="t-if">!this.pos.config.module_pos_hr || !this.pos.login</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('screen-login')]" position="after">
|
||||
<div t-if="this.pos.config.module_pos_hr and this.pos.login" class="screen-login flex-grow-1 d-flex align-items-center justify-content-center">
|
||||
<div class="d-flex bg-white p-3 gap-2 rounded">
|
||||
<input
|
||||
t-ref="autofocus"
|
||||
type="text"
|
||||
t-on-input="maskedInput"
|
||||
class="form-control form-control-lg rounded flex-grow-1"
|
||||
placeholder="Enter your PIN" />
|
||||
<button class="select-cashier btn btn-secondary px-4" t-on-click="() => this.selectCashier(false, true)">
|
||||
<i class="fa fa-users" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button class="btn btn-secondary mobile-scanner px-4" t-if="this.pos.config.module_pos_hr">
|
||||
<i class="fa fa-barcode" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
<xpath expr="//button[hasclass('open-register-btn')]/span" position="replace">
|
||||
<span t-if="this.pos.session.state !== 'opened'" class="d-flex flex-grow-1 align-items-center">Open Register</span>
|
||||
<span t-else="" class="d-flex flex-grow-1 align-items-center">Unlock Register</span>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import { OrderSummary } from "@point_of_sale/app/screens/product_screen/order_summary/order_summary";
|
||||
import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(OrderSummary.prototype, {
|
||||
async setLinePrice(line, price) {
|
||||
if (this.pos.cashierHasPriceControlRights()) {
|
||||
await super.setLinePrice(line, price);
|
||||
return;
|
||||
}
|
||||
|
||||
this.dialog.add(AlertDialog, {
|
||||
title: _t("Access Denied"),
|
||||
body: _t("You are not allowed to change the price of a product."),
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="pos_event.TicketScreen" t-inherit="point_of_sale.TicketScreen" t-inherit-mode="extension">
|
||||
<xpath expr="//button[hasclass('edit-order-payment')]" position="attributes">
|
||||
<attribute name="t-if">!this.pos.config.module_pos_hr || this.pos.employeeIsAdmin</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[hasclass('ticket-screen')]//div[hasclass('subpads d-flex flex-column')]" position="attributes">
|
||||
<attribute name="t-if">!this.pos.config.module_pos_hr or this.pos.cashier._role !== 'minimal'</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosStore } from "@point_of_sale/app/services/pos_store";
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
|
||||
patch(PosStore.prototype, {
|
||||
async setup() {
|
||||
this.employeeBuffer = [];
|
||||
await super.setup(...arguments);
|
||||
if (this.config.module_pos_hr) {
|
||||
this.login = Boolean(odoo.from_backend) && !this.config.module_pos_hr;
|
||||
if (!this.hasLoggedIn) {
|
||||
this.navigate("LoginScreen");
|
||||
}
|
||||
}
|
||||
browser.addEventListener("online", () => {
|
||||
this.employeeBuffer.forEach((employee) =>
|
||||
this.data.write("pos.session", [this.config.current_session_id.id], {
|
||||
employee_id: employee.id,
|
||||
})
|
||||
);
|
||||
this.employeeBuffer = [];
|
||||
});
|
||||
},
|
||||
get employeeIsAdmin() {
|
||||
const cashier = this.getCashier();
|
||||
return cashier._role === "manager";
|
||||
},
|
||||
checkPreviousLoggedCashier() {
|
||||
if (this.config.module_pos_hr) {
|
||||
const savedCashier = this._getConnectedCashier();
|
||||
if (savedCashier) {
|
||||
this.setCashier(savedCashier);
|
||||
} else {
|
||||
this.resetCashier();
|
||||
}
|
||||
} else {
|
||||
super.checkPreviousLoggedCashier(...arguments);
|
||||
}
|
||||
},
|
||||
async afterProcessServerData() {
|
||||
await super.afterProcessServerData(...arguments);
|
||||
if (this.config.module_pos_hr) {
|
||||
const saved_cashier = this._getConnectedCashier();
|
||||
this.hasLoggedIn = saved_cashier ? true : false;
|
||||
}
|
||||
},
|
||||
createNewOrder() {
|
||||
const order = super.createNewOrder(...arguments);
|
||||
|
||||
if (this.config.module_pos_hr) {
|
||||
order.employee_id = this.getCashier();
|
||||
}
|
||||
|
||||
return order;
|
||||
},
|
||||
setCashier(employee) {
|
||||
super.setCashier(employee);
|
||||
|
||||
if (this.config.module_pos_hr) {
|
||||
if (!this.data.network.offline) {
|
||||
this.data.write("pos.session", [this.config.current_session_id.id], {
|
||||
employee_id: employee.id,
|
||||
});
|
||||
} else {
|
||||
this.employeeBuffer.push(employee);
|
||||
}
|
||||
const o = this.getOrder();
|
||||
if (o && !o.getOrderlines().length) {
|
||||
// Order without lines can be considered to be un-owned by any employee.
|
||||
// We set the cashier on that order to the currently set employee.
|
||||
o.employee_id = employee;
|
||||
}
|
||||
if (!this.cashierHasPriceControlRights() && this.numpadMode === "price") {
|
||||
this.numpadMode = "quantity";
|
||||
}
|
||||
}
|
||||
},
|
||||
addLineToCurrentOrder(vals, opt = {}, configure = true) {
|
||||
vals.employee_id = false;
|
||||
|
||||
if (this.config.module_pos_hr) {
|
||||
const cashier = this.getCashier();
|
||||
|
||||
if (cashier && cashier.model.name === "hr.employee") {
|
||||
const order = this.getOrder();
|
||||
order.employee_id = this.getCashier();
|
||||
}
|
||||
}
|
||||
|
||||
return super.addLineToCurrentOrder(vals, opt, configure);
|
||||
},
|
||||
/**{name: null, id: null, barcode: null, user_id:null, pin:null}
|
||||
* If pos_hr is activated, return {name: string, id: int, barcode: string, pin: string, user_id: int}
|
||||
* @returns {null|*}
|
||||
*/
|
||||
getCashier() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return this.cashier;
|
||||
}
|
||||
return super.getCashier(...arguments);
|
||||
},
|
||||
getCashierUserId() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return this.cashier.user_id ? this.cashier.user_id : null;
|
||||
}
|
||||
return super.getCashierUserId(...arguments);
|
||||
},
|
||||
async logEmployeeMessage(action, message) {
|
||||
if (!this.config.module_pos_hr) {
|
||||
super.logEmployeeMessage(...arguments);
|
||||
return;
|
||||
}
|
||||
await this.data.call("pos.session", "log_partner_message", [
|
||||
this.session.id,
|
||||
this.cashier.work_contact_id?.id,
|
||||
action,
|
||||
message,
|
||||
]);
|
||||
},
|
||||
_getConnectedCashier() {
|
||||
if (!this.config.module_pos_hr) {
|
||||
return super._getConnectedCashier(...arguments);
|
||||
}
|
||||
const cashier_id = Number(sessionStorage.getItem(`connected_cashier_${this.config.id}`));
|
||||
if (cashier_id && this.models["hr.employee"].get(cashier_id)) {
|
||||
return this.models["hr.employee"].get(cashier_id);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
shouldShowOpeningControl() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return super.shouldShowOpeningControl(...arguments) && this.hasLoggedIn;
|
||||
}
|
||||
return super.shouldShowOpeningControl(...arguments);
|
||||
},
|
||||
async allowProductCreation() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return this.employeeIsAdmin && (await super.allowProductCreation());
|
||||
}
|
||||
return await super.allowProductCreation();
|
||||
},
|
||||
canEditPayment(order) {
|
||||
return super.canEditPayment(order) && (!this.config.module_pos_hr || this.employeeIsAdmin);
|
||||
},
|
||||
async handleUrlParams() {
|
||||
if (this.config.module_pos_hr && !this.cashier) {
|
||||
if (this.router.state.current !== "LoginScreen") {
|
||||
this.router.navigate("LoginScreen", {});
|
||||
}
|
||||
return;
|
||||
}
|
||||
return await super.handleUrlParams(...arguments);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import OrderPaymentValidation from "@point_of_sale/app/utils/order_payment_validation";
|
||||
import { patch } from "@web/core/utils/patch";
|
||||
|
||||
patch(OrderPaymentValidation.prototype, {
|
||||
async validateOrder(isForceValidate) {
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
this.order.employee_id = this.pos.getCashier();
|
||||
}
|
||||
|
||||
await super.validateOrder(...arguments);
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
/* global Sha1 */
|
||||
|
||||
import { _t } from "@web/core/l10n/translation";
|
||||
|
||||
import { NumberPopup } from "@point_of_sale/app/components/popups/number_popup/number_popup";
|
||||
import { useBarcodeReader } from "@point_of_sale/app/hooks/barcode_reader_hook";
|
||||
import { usePos } from "@point_of_sale/app/hooks/pos_hook";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
import { makeAwaitable, ask } from "@point_of_sale/app/utils/make_awaitable_dialog";
|
||||
import { CashierSelectionPopup } from "@pos_hr/app/components/popups/cashier_selection_popup/cashier_selection_popup";
|
||||
|
||||
export function useCashierSelector({ exclusive, onScan } = { onScan: () => {}, exclusive: false }) {
|
||||
const pos = usePos();
|
||||
const dialog = useService("dialog");
|
||||
const notification = useService("notification");
|
||||
useBarcodeReader(
|
||||
{
|
||||
async cashier(code) {
|
||||
const employee = pos.models["hr.employee"].find(
|
||||
(emp) => emp._barcode === Sha1.hash(code.code)
|
||||
);
|
||||
if (
|
||||
employee &&
|
||||
employee !== pos.getCashier() &&
|
||||
(!employee._pin || (await checkPin(employee)))
|
||||
) {
|
||||
onScan && onScan(employee);
|
||||
}
|
||||
return employee;
|
||||
},
|
||||
},
|
||||
exclusive
|
||||
);
|
||||
|
||||
async function checkPin(employee, pin = false) {
|
||||
let inputPin = pin;
|
||||
if (!pin) {
|
||||
inputPin = await makeAwaitable(dialog, NumberPopup, {
|
||||
formatDisplayedValue: (x) => x.replace(/./g, "•"),
|
||||
title: _t("Password?"),
|
||||
});
|
||||
} else {
|
||||
if (employee._pin !== Sha1.hash(inputPin)) {
|
||||
inputPin = await makeAwaitable(dialog, NumberPopup, {
|
||||
formatDisplayedValue: (x) => x.replace(/./g, "•"),
|
||||
title: _t("Password?"),
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!inputPin || employee._pin !== Sha1.hash(inputPin)) {
|
||||
notification.add(_t("PIN not found"), {
|
||||
type: "warning",
|
||||
title: _t(`Wrong PIN`),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a cashier, the returning value will either be an object or nothing (undefined)
|
||||
*/
|
||||
return async function selectCashier(pin = false, login = false, list = false) {
|
||||
if (!pos.config.module_pos_hr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const wrongPinNotification = () => {
|
||||
notification.add(_t("PIN not found"), {
|
||||
type: "warning",
|
||||
title: _t(`Wrong PIN`),
|
||||
});
|
||||
};
|
||||
|
||||
let employee = false;
|
||||
const allEmployees = pos.models["hr.employee"].filter(
|
||||
(employee) => employee.id !== pos.getCashier()?.id
|
||||
);
|
||||
const pinMatchEmployees = allEmployees.filter(
|
||||
(employee) => !pin || Sha1.hash(pin) === employee._pin
|
||||
);
|
||||
|
||||
if (!pinMatchEmployees.length && !pin) {
|
||||
await ask(dialog, {
|
||||
title: _t("No Cashiers"),
|
||||
body: _t("There is no cashier available."),
|
||||
});
|
||||
return;
|
||||
} else if (pin && !pinMatchEmployees.length) {
|
||||
wrongPinNotification();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pinMatchEmployees.length > 1 || list) {
|
||||
employee = await makeAwaitable(dialog, CashierSelectionPopup, {
|
||||
currentCashier: pos.getCashier() || undefined,
|
||||
employees: allEmployees,
|
||||
});
|
||||
|
||||
if (!employee) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pin && Sha1.hash(pin) !== employee._pin) {
|
||||
wrongPinNotification();
|
||||
return;
|
||||
}
|
||||
} else if (pinMatchEmployees.length === 1) {
|
||||
employee = pinMatchEmployees[0];
|
||||
}
|
||||
|
||||
if (!pin && employee && employee._pin) {
|
||||
const result = await checkPin(employee);
|
||||
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (login && employee) {
|
||||
pos.hasLoggedIn = true;
|
||||
pos.setCashier(employee);
|
||||
}
|
||||
|
||||
const currentScreen = pos.router.state.current;
|
||||
if (currentScreen === "LoginScreen" && login && employee) {
|
||||
const selectedScreen = pos.defaultPage;
|
||||
const props = {
|
||||
...selectedScreen.params,
|
||||
orderUuid: pos.selectedOrderUuid,
|
||||
};
|
||||
if (selectedScreen.page === "FloorScreen") {
|
||||
delete props.orderUuid;
|
||||
}
|
||||
pos.navigate(selectedScreen.page, props);
|
||||
}
|
||||
|
||||
return employee;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
.pos .login-overlay{
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height:100%;
|
||||
z-index:1000;
|
||||
background: linear-gradient(to right bottom, #77717e, #c9a8a9);
|
||||
}
|
||||
.pos .login-overlay:before {
|
||||
content: '';
|
||||
background-image: url(../../img/login-bg-overlay.svg);
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height:100%;
|
||||
}
|
||||
.pos .screen-login{
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
margin: auto;
|
||||
max-width: 550px;
|
||||
width:100%;
|
||||
height:300px;
|
||||
text-align:center;
|
||||
font-size:20px;
|
||||
font-weight:bold;
|
||||
background-color: #F0EEEE;
|
||||
border-radius: 3px;
|
||||
z-index:1200;
|
||||
font-family: 'Lato';
|
||||
}
|
||||
.pos .login-title{
|
||||
height: 40%;
|
||||
vertical-align: middle;
|
||||
line-height: 5;
|
||||
font-size: larger;
|
||||
}
|
||||
.pos .login-body{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height:37%;
|
||||
}
|
||||
|
||||
.pos .login-footer{
|
||||
height:18%;
|
||||
}
|
||||
|
||||
.pos .login-element{
|
||||
float: left;
|
||||
width: 40%;
|
||||
height: 60%;
|
||||
}
|
||||
.pos .login-barcode-img{
|
||||
width: 80px;
|
||||
height: 55px;
|
||||
background: white;
|
||||
border: 0px;
|
||||
}
|
||||
.pos .login-barcode-text{
|
||||
color: #999999;
|
||||
font-size: 13px;
|
||||
padding-top: 0.2em;
|
||||
}
|
||||
.pos .login-or{
|
||||
font-size: 15px;
|
||||
font-style: italic;
|
||||
float: left;
|
||||
width: 10%;
|
||||
height: 100%;
|
||||
line-height: 5;
|
||||
}
|
||||
.pos .login-button{
|
||||
font-size: initial;
|
||||
height: 100%;
|
||||
color: #555555;
|
||||
border-radius: 5px;
|
||||
}
|
||||
@media screen and (max-width: 576px) {
|
||||
.pos .screen-login {
|
||||
font-family: 'Lato', sans-serif;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
.pos .login-body {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.pos .login-button {
|
||||
color: #fff;
|
||||
background-color: #00A09D;
|
||||
border-color: #00A09D;
|
||||
height: 38px;
|
||||
}
|
||||
.pos .login-barcode-text {
|
||||
color: #adb5bd;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.pos .login-element .o_barcode_mobile_container .o_mobile_barcode {
|
||||
top:0;
|
||||
height: 55px;
|
||||
}
|
||||
}
|
||||
|
||||
.pos .pos-rightheader .header-button.lock-button {
|
||||
font-size: 20px;
|
||||
color: rgb(94, 185, 55);
|
||||
transition: all 200ms ease-in-out;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
.pos .pos-rightheader .header-button.lock-button:hover {
|
||||
color: rgb(197, 52, 0);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
odoo.define('pos_hr.CashierName', function (require) {
|
||||
'use strict';
|
||||
|
||||
const CashierName = require('point_of_sale.CashierName');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
const SelectCashierMixin = require('pos_hr.SelectCashierMixin');
|
||||
const { useBarcodeReader } = require('point_of_sale.custom_hooks');
|
||||
|
||||
const PosHrCashierName = (CashierName) =>
|
||||
class extends SelectCashierMixin(CashierName) {
|
||||
setup() {
|
||||
super.setup();
|
||||
useBarcodeReader({ cashier: this.barcodeCashierAction });
|
||||
}
|
||||
//@Override
|
||||
get avatar() {
|
||||
if (this.env.pos.config.module_pos_hr) {
|
||||
const cashier = this.env.pos.get_cashier();
|
||||
if (!(cashier && cashier.id)) {
|
||||
return '';
|
||||
}
|
||||
return `/web/image/hr.employee.public/${cashier.id}/avatar_128`;
|
||||
}
|
||||
return super.avatar;
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Component.extend(CashierName, PosHrCashierName);
|
||||
|
||||
return CashierName;
|
||||
});
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
odoo.define('pos_hr.chrome', function (require) {
|
||||
'use strict';
|
||||
|
||||
const Chrome = require('point_of_sale.Chrome');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
const PosHrChrome = (Chrome) =>
|
||||
class extends Chrome {
|
||||
async start() {
|
||||
await super.start();
|
||||
if (this.env.pos.config.module_pos_hr) this.showTempScreen('LoginScreen');
|
||||
}
|
||||
get headerButtonIsShown() {
|
||||
return !this.env.pos.config.module_pos_hr || this.env.pos.get_cashier().role == 'manager' || this.env.pos.get_cashier_user_id() === this.env.pos.user.id;
|
||||
}
|
||||
showCashMoveButton() {
|
||||
return super.showCashMoveButton() && (!this.env.pos.cashier || this.env.pos.cashier.role == 'manager');
|
||||
}
|
||||
shouldShowCashControl() {
|
||||
if (this.env.pos.config.module_pos_hr){
|
||||
return super.shouldShowCashControl() && this.env.pos.hasLoggedIn;
|
||||
}
|
||||
return super.shouldShowCashControl();
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Component.extend(Chrome, PosHrChrome);
|
||||
|
||||
return Chrome;
|
||||
});
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
odoo.define('point_of_sale.HeaderLockButton', function(require) {
|
||||
'use strict';
|
||||
|
||||
const PosComponent = require('point_of_sale.PosComponent');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
const { useState } = owl;
|
||||
|
||||
class HeaderLockButton extends PosComponent {
|
||||
setup() {
|
||||
super.setup();
|
||||
this.state = useState({ isUnlockIcon: true, title: 'Unlocked' });
|
||||
}
|
||||
async showLoginScreen() {
|
||||
this.env.pos.reset_cashier();
|
||||
await this.showTempScreen('LoginScreen');
|
||||
}
|
||||
onMouseOver(isMouseOver) {
|
||||
this.state.isUnlockIcon = !isMouseOver;
|
||||
this.state.title = isMouseOver ? 'Lock' : 'Unlocked';
|
||||
}
|
||||
}
|
||||
HeaderLockButton.template = "HeaderLockButton";
|
||||
|
||||
Registries.Component.add(HeaderLockButton);
|
||||
|
||||
return HeaderLockButton;
|
||||
});
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
odoo.define('pos_hr.LoginScreen', function (require) {
|
||||
'use strict';
|
||||
|
||||
const PosComponent = require('point_of_sale.PosComponent');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
const SelectCashierMixin = require('pos_hr.SelectCashierMixin');
|
||||
const { useBarcodeReader } = require('point_of_sale.custom_hooks');
|
||||
|
||||
class LoginScreen extends SelectCashierMixin(PosComponent) {
|
||||
setup() {
|
||||
super.setup();
|
||||
useBarcodeReader({cashier: this.barcodeCashierAction}, true);
|
||||
}
|
||||
async selectCashier() {
|
||||
if (await super.selectCashier()) {
|
||||
this.back();
|
||||
}
|
||||
}
|
||||
async barcodeCashierAction(code) {
|
||||
if (await super.barcodeCashierAction(code) && this.env.pos.get_cashier().id) {
|
||||
this.back();
|
||||
}
|
||||
}
|
||||
back() {
|
||||
this.props.resolve({ confirmed: false, payload: false });
|
||||
this.trigger('close-temp-screen');
|
||||
this.env.pos.hasLoggedIn = true;
|
||||
this.env.posbus.trigger('start-cash-control');
|
||||
}
|
||||
confirm() {
|
||||
this.props.resolve({ confirmed: true, payload: true });
|
||||
this.trigger('close-temp-screen');
|
||||
}
|
||||
get shopName() {
|
||||
return this.env.pos.config.name;
|
||||
}
|
||||
}
|
||||
LoginScreen.template = 'LoginScreen';
|
||||
|
||||
Registries.Component.add(LoginScreen);
|
||||
|
||||
return LoginScreen;
|
||||
});
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
odoo.define('pos_hr.PaymentScreen', function (require) {
|
||||
'use strict';
|
||||
|
||||
const PaymentScreen = require('point_of_sale.PaymentScreen');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
const PosHrPaymentScreen = (PaymentScreen_) =>
|
||||
class extends PaymentScreen_ {
|
||||
async _finalizeValidation() {
|
||||
this.currentOrder.cashier = this.env.pos.get_cashier();
|
||||
await super._finalizeValidation();
|
||||
}
|
||||
};
|
||||
|
||||
Registries.Component.extend(PaymentScreen, PosHrPaymentScreen);
|
||||
|
||||
return PaymentScreen;
|
||||
});
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/* global Sha1 */
|
||||
odoo.define('pos_hr.SelectCashierMixin', function (require) {
|
||||
'use strict';
|
||||
|
||||
const SelectCashierMixin = (PosComponent) => class ComponentWithSelectCashierMixin extends PosComponent {
|
||||
async askPin(employee) {
|
||||
const { confirmed, payload: inputPin } = await this.showPopup('NumberPopup', {
|
||||
isPassword: true,
|
||||
title: this.env._t('Password ?'),
|
||||
startingValue: null,
|
||||
});
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
if (employee.pin === Sha1.hash(inputPin)) {
|
||||
return employee;
|
||||
} else {
|
||||
await this.showPopup('ErrorPopup', {
|
||||
title: this.env._t('Incorrect Password'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a cashier, the returning value will either be an object or nothing (undefined)
|
||||
*/
|
||||
async selectCashier() {
|
||||
if (this.env.pos.config.module_pos_hr) {
|
||||
const employeesList = this.env.pos.employees
|
||||
.filter((employee) => employee.id !== this.env.pos.get_cashier().id)
|
||||
.map((employee) => {
|
||||
return {
|
||||
id: employee.id,
|
||||
item: employee,
|
||||
label: employee.name,
|
||||
isSelected: false,
|
||||
};
|
||||
});
|
||||
let {confirmed, payload: employee} = await this.showPopup('SelectionPopup', {
|
||||
title: this.env._t('Change Cashier'),
|
||||
list: employeesList,
|
||||
});
|
||||
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (employee && employee.pin) {
|
||||
employee = await this.askPin(employee);
|
||||
}
|
||||
if (employee) {
|
||||
this.env.pos.set_cashier(employee);
|
||||
}
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
|
||||
async barcodeCashierAction(code) {
|
||||
const employee = this.env.pos.employees.find(
|
||||
(emp) => emp.barcode === Sha1.hash(code.code)
|
||||
);
|
||||
if (employee && employee !== this.env.pos.get_cashier() && (!employee.pin || (await this.askPin(employee)))) {
|
||||
this.env.pos.set_cashier(employee);
|
||||
}
|
||||
return employee;
|
||||
}
|
||||
}
|
||||
|
||||
return SelectCashierMixin;
|
||||
});
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
odoo.define('pos_hr.employees', function (require) {
|
||||
"use strict";
|
||||
|
||||
var { PosGlobalState, Order } = require('point_of_sale.models');
|
||||
const Registries = require('point_of_sale.Registries');
|
||||
|
||||
|
||||
const PosHrPosGlobalState = (PosGlobalState) => class PosHrPosGlobalState extends PosGlobalState {
|
||||
async _processData(loadedData) {
|
||||
await super._processData(...arguments);
|
||||
if (this.config.module_pos_hr) {
|
||||
this.employees = loadedData['hr.employee'];
|
||||
this.employee_by_id = loadedData['employee_by_id'];
|
||||
this.reset_cashier();
|
||||
}
|
||||
}
|
||||
async after_load_server_data() {
|
||||
await super.after_load_server_data(...arguments);
|
||||
if (this.config.module_pos_hr) {
|
||||
this.hasLoggedIn = !this.config.module_pos_hr;
|
||||
}
|
||||
}
|
||||
reset_cashier() {
|
||||
this.cashier = {name: null, id: null, barcode: null, user_id: null, pin: null, role: null};
|
||||
}
|
||||
set_cashier(employee) {
|
||||
this.cashier = employee;
|
||||
const selectedOrder = this.get_order();
|
||||
if (selectedOrder && !selectedOrder.get_orderlines().length) {
|
||||
// Order without lines can be considered to be un-owned by any employee.
|
||||
// We set the cashier on that order to the currently set employee.
|
||||
selectedOrder.cashier = employee;
|
||||
}
|
||||
if (!this.cashierHasPriceControlRights() && this.numpadMode === 'price') {
|
||||
this.numpadMode = 'quantity';
|
||||
}
|
||||
}
|
||||
|
||||
/**{name: null, id: null, barcode: null, user_id:null, pin:null}
|
||||
* If pos_hr is activated, return {name: string, id: int, barcode: string, pin: string, user_id: int}
|
||||
* @returns {null|*}
|
||||
*/
|
||||
get_cashier() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return this.cashier;
|
||||
}
|
||||
return super.get_cashier();
|
||||
}
|
||||
get_cashier_user_id() {
|
||||
if (this.config.module_pos_hr) {
|
||||
return this.cashier.user_id ? this.cashier.user_id : null;
|
||||
}
|
||||
return super.get_cashier_user_id();
|
||||
}
|
||||
}
|
||||
Registries.Model.extend(PosGlobalState, PosHrPosGlobalState);
|
||||
|
||||
|
||||
const PosHrOrder = (Order) => class PosHrOrder extends Order {
|
||||
constructor(obj, options) {
|
||||
super(...arguments);
|
||||
if (!options.json && this.pos.config.module_pos_hr) {
|
||||
this.cashier = this.pos.get_cashier();
|
||||
}
|
||||
}
|
||||
init_from_JSON(json) {
|
||||
super.init_from_JSON(...arguments);
|
||||
if (this.pos.config.module_pos_hr && json.employee_id) {
|
||||
this.cashier = this.pos.employee_by_id[json.employee_id];
|
||||
}
|
||||
}
|
||||
export_as_JSON() {
|
||||
const json = super.export_as_JSON(...arguments);
|
||||
if (this.pos.config.module_pos_hr) {
|
||||
json.employee_id = this.cashier ? this.cashier.id : false;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
||||
Registries.Model.extend(Order, PosHrOrder);
|
||||
|
||||
});
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="CashierName" t-inherit="point_of_sale.CashierName" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//div" position="attributes">
|
||||
<attribute name="t-on-click">selectCashier</attribute>
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="Chrome" t-inherit="point_of_sale.Chrome" t-inherit-mode="extension" owl="1">
|
||||
<xpath expr="//HeaderButton" position="replace">
|
||||
<HeaderLockButton t-if="env.pos.config.module_pos_hr" />
|
||||
<HeaderButton t-if="headerButtonIsShown" />
|
||||
</xpath>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
|
||||
<t t-name="HeaderLockButton" owl="1">
|
||||
<div class="header-button lock-button" t-on-mouseover="() => this.onMouseOver(true)"
|
||||
t-on-click="showLoginScreen" t-on-mouseout="() => this.onMouseOver(false)">
|
||||
<span class="lock-button">
|
||||
<i class="fa"
|
||||
t-att-class="{ 'fa-unlock': state.isUnlockIcon, 'fa-lock': !state.isUnlockIcon }"
|
||||
role="img" t-att-aria-label="state.title" t-att-title="state.title"></i>
|
||||
</span>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="LoginScreen" owl="1">
|
||||
<div class="login-overlay">
|
||||
<div class="screen-login">
|
||||
<div class="login-title"><small>Log in to </small>
|
||||
<t t-esc="shopName" />
|
||||
</div>
|
||||
<div class="login-body">
|
||||
<span class="login-element">
|
||||
<img class="login-barcode-img"
|
||||
src="/point_of_sale/static/img/barcode.png" />
|
||||
<div class="login-barcode-text">Scan your badge</div>
|
||||
</span>
|
||||
<span class="login-or">or</span>
|
||||
<span class="login-element">
|
||||
<button class="login-button select-cashier"
|
||||
t-on-click="selectCashier">Select Cashier</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
odoo.define('point_of_sale.tour.PosHr', function (require) {
|
||||
'use strict';
|
||||
|
||||
const { PosHr } = require('pos_hr.tour.PosHrTourMethods');
|
||||
const { ProductScreen } = require('point_of_sale.tour.ProductScreenTourMethods');
|
||||
const { TicketScreen } = require('point_of_sale.tour.TicketScreenTourMethods');
|
||||
const { Chrome } = require('point_of_sale.tour.ChromeTourMethods');
|
||||
const { ErrorPopup } = require('point_of_sale.tour.ErrorPopupTourMethods');
|
||||
const { NumberPopup } = require('point_of_sale.tour.NumberPopupTourMethods');
|
||||
const { SelectionPopup } = require('point_of_sale.tour.SelectionPopupTourMethods');
|
||||
const { getSteps, startSteps } = require('point_of_sale.tour.utils');
|
||||
const Tour = require('web_tour.tour');
|
||||
|
||||
startSteps();
|
||||
|
||||
PosHr.check.loginScreenIsShown();
|
||||
PosHr.do.clickLoginButton();
|
||||
SelectionPopup.check.isShown();
|
||||
SelectionPopup.check.hasSelectionItem('Pos Employee1');
|
||||
SelectionPopup.check.hasSelectionItem('Pos Employee2');
|
||||
SelectionPopup.check.hasSelectionItem('Mitchell Admin');
|
||||
SelectionPopup.do.clickItem('Pos Employee1');
|
||||
NumberPopup.check.isShown();
|
||||
NumberPopup.do.pressNumpad('2 5');
|
||||
NumberPopup.check.inputShownIs('••');
|
||||
NumberPopup.do.pressNumpad('8 1');
|
||||
NumberPopup.check.inputShownIs('••••');
|
||||
NumberPopup.do.clickConfirm();
|
||||
ErrorPopup.check.isShown();
|
||||
ErrorPopup.do.clickConfirm();
|
||||
PosHr.do.clickLoginButton();
|
||||
SelectionPopup.do.clickItem('Pos Employee1');
|
||||
NumberPopup.check.isShown();
|
||||
NumberPopup.do.pressNumpad('2 5');
|
||||
NumberPopup.check.inputShownIs('••');
|
||||
NumberPopup.do.pressNumpad('8 0');
|
||||
NumberPopup.check.inputShownIs('••••');
|
||||
NumberPopup.do.clickConfirm();
|
||||
ProductScreen.check.isShown();
|
||||
ProductScreen.do.confirmOpeningPopup();
|
||||
PosHr.check.cashierNameIs('Pos Employee1');
|
||||
PosHr.do.clickCashierName();
|
||||
SelectionPopup.do.clickItem('Mitchell Admin');
|
||||
PosHr.check.cashierNameIs('Mitchell Admin');
|
||||
PosHr.do.clickLockButton();
|
||||
PosHr.do.clickLoginButton();
|
||||
SelectionPopup.do.clickItem('Pos Employee2');
|
||||
NumberPopup.do.pressNumpad('1 2');
|
||||
NumberPopup.check.inputShownIs('••');
|
||||
NumberPopup.do.pressNumpad('3 4');
|
||||
NumberPopup.check.inputShownIs('••••');
|
||||
NumberPopup.do.clickConfirm();
|
||||
ProductScreen.check.isShown();
|
||||
ProductScreen.do.clickHomeCategory();
|
||||
|
||||
// Create orders and check if the ticket list has the right employee for each order
|
||||
// order for employee 2
|
||||
ProductScreen.exec.addOrderline('Desk Pad', '1', '2');
|
||||
ProductScreen.check.totalAmountIs('2.0')
|
||||
Chrome.do.clickTicketButton();
|
||||
TicketScreen.check.nthRowContains(2, 'Pos Employee2');
|
||||
|
||||
// order for employee 1
|
||||
PosHr.do.clickLockButton();
|
||||
PosHr.exec.login('Pos Employee1', '2580');
|
||||
TicketScreen.do.clickNewTicket();
|
||||
ProductScreen.exec.addOrderline('Desk Pad', '1', '4');
|
||||
ProductScreen.check.totalAmountIs('4.0')
|
||||
Chrome.do.clickTicketButton();
|
||||
TicketScreen.check.nthRowContains(2, 'Pos Employee2');
|
||||
TicketScreen.check.nthRowContains(3, 'Pos Employee1');
|
||||
|
||||
// order for admin
|
||||
PosHr.do.clickCashierName();
|
||||
SelectionPopup.do.clickItem('Mitchell Admin');
|
||||
PosHr.check.cashierNameIs('Mitchell Admin');
|
||||
TicketScreen.do.clickNewTicket();
|
||||
ProductScreen.exec.addOrderline('Desk Pad', '1', '8');
|
||||
ProductScreen.check.totalAmountIs('8.0')
|
||||
Chrome.do.clickTicketButton();
|
||||
TicketScreen.check.nthRowContains(4, 'Mitchell Admin');
|
||||
|
||||
Tour.register('PosHrTour', { test: true, url: '/pos/ui' }, getSteps());
|
||||
});
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
odoo.define('pos_hr.tour.PosHrTourMethods', function (require) {
|
||||
'use strict';
|
||||
|
||||
const { createTourMethods } = require('point_of_sale.tour.utils');
|
||||
const { SelectionPopup } = require('point_of_sale.tour.SelectionPopupTourMethods');
|
||||
const { NumberPopup } = require('point_of_sale.tour.NumberPopupTourMethods');
|
||||
|
||||
class Do {
|
||||
clickLoginButton() {
|
||||
return [
|
||||
{
|
||||
content: 'click login button',
|
||||
trigger: '.login-overlay .login-button.select-cashier',
|
||||
},
|
||||
];
|
||||
}
|
||||
clickLockButton() {
|
||||
return [
|
||||
{
|
||||
content: 'click lock button',
|
||||
trigger: '.header-button .lock-button',
|
||||
},
|
||||
];
|
||||
}
|
||||
clickCashierName() {
|
||||
return [
|
||||
{
|
||||
content: 'click cashier name',
|
||||
trigger: '.oe_status .username',
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
class Check {
|
||||
loginScreenIsShown() {
|
||||
return [
|
||||
{
|
||||
content: 'login screen is shown',
|
||||
trigger: '.login-overlay .screen-login .login-body',
|
||||
run: () => {},
|
||||
},
|
||||
];
|
||||
}
|
||||
cashierNameIs(name) {
|
||||
return [
|
||||
{
|
||||
content: `logged cashier is '${name}'`,
|
||||
trigger: `.pos .oe_status .username:contains("${name}")`,
|
||||
run: () => {},
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
class Execute {
|
||||
login(name, pin) {
|
||||
const res = this._do.clickLoginButton();
|
||||
res.push(...SelectionPopup._do.clickItem(name));
|
||||
if (pin) {
|
||||
res.push(...NumberPopup._do.pressNumpad(pin.split('').join(' ')));
|
||||
res.push(...NumberPopup._do.clickConfirm());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
return createTourMethods('PosHr', Do, Check, Execute);
|
||||
});
|
||||
|
|
@ -0,0 +1,406 @@
|
|||
import * as PosHr from "@pos_hr/../tests/tours/utils/pos_hr_helpers";
|
||||
import * as ProductScreen from "@point_of_sale/../tests/pos/tours/utils/product_screen_util";
|
||||
import * as TicketScreen from "@point_of_sale/../tests/pos/tours/utils/ticket_screen_util";
|
||||
import * as ReceiptScreen from "@point_of_sale/../tests/pos/tours/utils/receipt_screen_util";
|
||||
import * as PaymentScreen from "@point_of_sale/../tests/pos/tours/utils/payment_screen_util";
|
||||
import * as Chrome from "@point_of_sale/../tests/pos/tours/utils/chrome_util";
|
||||
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
|
||||
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
|
||||
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
|
||||
import * as BackendUtils from "@point_of_sale/../tests/pos/tours/utils/backend_utils";
|
||||
import * as Utils from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { negate, scan_barcode } from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
|
||||
registry.category("web_tour.tours").add("PosHrTour", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1"),
|
||||
SelectionPopup.has("Pos Employee2"),
|
||||
SelectionPopup.has("Mitchell Admin"),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
NumberPopup.enterValue("25"),
|
||||
NumberPopup.isShown("••"),
|
||||
{
|
||||
trigger: "body",
|
||||
run: () => {
|
||||
window.dispatchEvent(new KeyboardEvent("keyup", { key: "8" }));
|
||||
},
|
||||
},
|
||||
NumberPopup.isShown("•••"),
|
||||
NumberPopup.enterValue("1"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
// after trying to close the number popup, the error popup should be shown
|
||||
// successfully confirming the dialog would imply that the error popup is actually shown
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
|
||||
NumberPopup.enterValue("25"),
|
||||
NumberPopup.isShown("••"),
|
||||
NumberPopup.enterValue("80"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.isShown(),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Pos Employee2", { run: "click" }),
|
||||
NumberPopup.enterValue("12"),
|
||||
NumberPopup.isShown("••"),
|
||||
NumberPopup.enterValue("34"),
|
||||
NumberPopup.isShown("••••"),
|
||||
Dialog.confirm(),
|
||||
ProductScreen.isShown(),
|
||||
|
||||
// Create orders and check if the ticket list has the right employee for each order
|
||||
// order for employee 2
|
||||
ProductScreen.addOrderline("Desk Pad", "1"),
|
||||
ProductScreen.totalAmountIs("1.98"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(1, "Pos Employee2", false),
|
||||
|
||||
// order for employee 1
|
||||
PosHr.clickLockButton(),
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.login("Pos Employee1", "2580"),
|
||||
Chrome.createFloatingOrder(),
|
||||
ProductScreen.addOrderline("Desk Pad", "1"),
|
||||
ProductScreen.totalAmountIs("1.98"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(1, "Pos Employee2", false),
|
||||
TicketScreen.nthRowContains(2, "Pos Employee1", false),
|
||||
|
||||
// Cash in/out should be accessible for all users.
|
||||
Chrome.clickMenuOption("Cash In/Out"),
|
||||
Dialog.discard(),
|
||||
|
||||
// order for admin
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.createFloatingOrder(),
|
||||
ProductScreen.addOrderline("Desk Pad", "1", "8"),
|
||||
ProductScreen.totalAmountIs("8.0"),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.nthRowContains(3, "Mitchell Admin", false),
|
||||
|
||||
// Close register should be accessible by the admin user.
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Dialog.is("Closing Register"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierStayLogged", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Pos Employee1"),
|
||||
SelectionPopup.has("Pos Employee2"),
|
||||
SelectionPopup.has("Mitchell Admin"),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
PosHr.refreshPage(),
|
||||
ProductScreen.isShown(),
|
||||
Chrome.clickMenuButton(),
|
||||
PosHr.clickLockButton(),
|
||||
PosHr.refreshPage(),
|
||||
PosHr.loginScreenIsShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierCanSeeProductInfo", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.clickInfoProduct("product_a", [Dialog.confirm("Close")]),
|
||||
Dialog.isNot(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("CashierCannotClose", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
Chrome.clickMenuButton(),
|
||||
{
|
||||
trigger: negate(`span.dropdown-item:contains("Close Register")`),
|
||||
},
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickMenuButton(),
|
||||
{
|
||||
trigger: `span.dropdown-item:contains("Close Register")`,
|
||||
},
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_basic_user_can_change_price", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.addOrderline("Desk Pad", "1", "10", "10"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_change_on_rights_reflected_directly", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
|
||||
BackendUtils.editShopConfiguration("Shop"),
|
||||
{
|
||||
trigger: ".o_tag:contains('Pos Employee1') .o_delete",
|
||||
run: "click",
|
||||
},
|
||||
BackendUtils.saveConfiguration(),
|
||||
{
|
||||
trigger: ".o_main_navbar .o-dropdown-item:contains('Dashboard')",
|
||||
run: "click",
|
||||
},
|
||||
{
|
||||
trigger: ".btn:contains('Continue Selling')",
|
||||
run: "click",
|
||||
expectUnloadPage: true,
|
||||
},
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
Utils.negateStep(...SelectionPopup.has("Pos Employee1")),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_minimal_employee_refund", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Minimal Employee", { run: "click" }),
|
||||
Chrome.clickOrders(),
|
||||
TicketScreen.selectFilter("Paid"),
|
||||
TicketScreen.selectOrder("001"),
|
||||
{
|
||||
trigger: negate(".subpads"),
|
||||
},
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
TicketScreen.selectFilter("Paid"),
|
||||
TicketScreen.selectOrder("001"),
|
||||
{
|
||||
trigger: ".subpads",
|
||||
},
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_cashier_changed_in_receipt", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.addOrderline("product_a", "1"),
|
||||
ProductScreen.clickPayButton(),
|
||||
PaymentScreen.clickPaymentMethod("Bank"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
PaymentScreen.clickValidate(),
|
||||
ReceiptScreen.cashierNameExists("Test"), // Test Employee 3 (Take the first word)
|
||||
ReceiptScreen.clickNextOrder(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_cost_and_margin_visibility", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Dialog.confirm("Open Register"),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
{
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
},
|
||||
Dialog.confirm("Close"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
{
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
},
|
||||
Dialog.confirm("Close"),
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 4", { run: "click" }),
|
||||
ProductScreen.clickInfoProduct("product_a"),
|
||||
Utils.negateStep({
|
||||
trigger: ".section-financials :contains('Margin')",
|
||||
}),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("pos_hr_go_backend_closed_registered", {
|
||||
steps: () =>
|
||||
[
|
||||
// Admin --> 403: not the one that opened the session
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Employee with user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Employee without user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Manager without user --> 403
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
PosHr.loginScreenIsShown(),
|
||||
|
||||
// Manager that opened the session --> access granted
|
||||
Chrome.clickBtn("Backend"),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651").map((step, index, array) => {
|
||||
if (index === array.length - 1) {
|
||||
return {
|
||||
...step,
|
||||
expectUnloadPage: true,
|
||||
};
|
||||
}
|
||||
return step;
|
||||
}),
|
||||
PosHr.loginScreenIsNotShown().map((step) => ({ ...step, expectUnloadPage: true })),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("pos_hr_go_backend_opened_registered", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
|
||||
// Admin --> 403: not the one that opened the session
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Employee with user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
Chrome.notExistMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Employee without user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Employee 3", { run: "click" }),
|
||||
Chrome.notExistMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Manager without user --> 403
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
|
||||
// Manager that opened the session --> access granted
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651"),
|
||||
Chrome.existMenuOption("Close Register"),
|
||||
Chrome.clickMenuOption("Backend", { expectUnloadPage: true }),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry
|
||||
.category("web_tour.tours")
|
||||
.add("pos_hr_go_backend_opened_registered_different_user_logged", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Unlock Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
|
||||
// Employee, connected user
|
||||
SelectionPopup.has("Pos Employee1", { run: "click" }),
|
||||
PosHr.enterPin("2580"),
|
||||
Chrome.existMenuOption("Backend"),
|
||||
|
||||
// Manager that opened the session, not connected user
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 1", { run: "click" }),
|
||||
PosHr.enterPin("5651"),
|
||||
Chrome.notExistMenuOption("Backend"),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_maximum_closing_difference", {
|
||||
steps: () =>
|
||||
[
|
||||
Chrome.clickBtn("Open Register"),
|
||||
PosHr.clickLoginButton(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
ProductScreen.enterOpeningAmount("10"),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Test Manager 2", { run: "click" }),
|
||||
PosHr.enterPin("5652"),
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Chrome.clickBtn("Close Register"),
|
||||
{
|
||||
trigger: negate(`button:contains("Proceed anyway")`),
|
||||
},
|
||||
Chrome.clickBtn("Ok"),
|
||||
Chrome.clickBtn("Discard"),
|
||||
|
||||
PosHr.clickCashierName(),
|
||||
SelectionPopup.has("Mitchell Admin", { run: "click" }),
|
||||
Chrome.clickMenuOption("Close Register"),
|
||||
Chrome.clickBtn("Close Register"),
|
||||
Chrome.hasBtn("Proceed anyway"),
|
||||
Chrome.clickBtn("Proceed anyway", { expectUnloadPage: true }),
|
||||
PosHr.loginScreenIsShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
||||
registry.category("web_tour.tours").add("test_scan_employee_barcode_with_pos_hr_disabled", {
|
||||
steps: () =>
|
||||
[
|
||||
// scan a barcode with 041 as prefix for cashiers
|
||||
scan_barcode("041123"),
|
||||
Chrome.clickBtn("Open Register"),
|
||||
ProductScreen.isShown(),
|
||||
].flat(),
|
||||
});
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
import * as SelectionPopup from "@point_of_sale/../tests/generic_helpers/selection_popup_util";
|
||||
import * as Dialog from "@point_of_sale/../tests/generic_helpers/dialog_util";
|
||||
import * as NumberPopup from "@point_of_sale/../tests/generic_helpers/number_popup_util";
|
||||
import { negate } from "@point_of_sale/../tests/generic_helpers/utils";
|
||||
|
||||
export function clickLoginButton() {
|
||||
return [
|
||||
{
|
||||
content: "click login button",
|
||||
trigger: ".login-overlay .select-cashier",
|
||||
run: "click",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function clickCashierName() {
|
||||
return [
|
||||
{
|
||||
content: "click cashier name",
|
||||
trigger: ".cashier-name",
|
||||
run: "click",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function loginScreenIsShown() {
|
||||
return [
|
||||
{
|
||||
content: "login screen is shown",
|
||||
trigger: ".login-overlay .screen-login",
|
||||
},
|
||||
];
|
||||
}
|
||||
export function loginScreenIsNotShown() {
|
||||
return [
|
||||
{
|
||||
content: "login screen is not shown",
|
||||
trigger: negate(".login-overlay .screen-login"),
|
||||
},
|
||||
];
|
||||
}
|
||||
export function cashierNameIs(name) {
|
||||
return [
|
||||
{
|
||||
isActive: ["desktop"],
|
||||
content: `logged cashier is '${name}'`,
|
||||
trigger: `.pos .oe_status .username:contains("${name}")`,
|
||||
},
|
||||
{
|
||||
isActive: ["mobile"],
|
||||
content: `logged cashier is '${name}'`,
|
||||
trigger: `.pos .oe_status img[alt="${name}"]`,
|
||||
},
|
||||
];
|
||||
}
|
||||
export function login(name, pin) {
|
||||
const res = [...clickLoginButton(), ...SelectionPopup.has(name, { run: "click" })];
|
||||
if (!pin) {
|
||||
return res;
|
||||
}
|
||||
return res.concat(enterPin(pin));
|
||||
}
|
||||
export function enterPin(pin) {
|
||||
return [...NumberPopup.enterValue(pin), ...NumberPopup.isShown("••••"), Dialog.confirm()];
|
||||
}
|
||||
export function clickLockButton() {
|
||||
return {
|
||||
content: "Click on the menu button",
|
||||
trigger: ".pos-rightheader i.fa-unlock",
|
||||
run: "click",
|
||||
};
|
||||
}
|
||||
|
||||
export function refreshPage() {
|
||||
return [
|
||||
{
|
||||
trigger: ".pos",
|
||||
run: () => {
|
||||
window.location.reload();
|
||||
},
|
||||
expectUnloadPage: true,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { CashierName } from "@point_of_sale/app/components/navbar/cashier_name/cashier_name";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("avatarAndCssClass", async () => {
|
||||
await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashierName, {});
|
||||
expect(comp.avatar).toBe("/web/image/hr.employee.public/2/avatar_128");
|
||||
expect(comp.cssClass).toMatchObject({ oe_status: true });
|
||||
});
|
||||
test("selectCashier", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashierName, {});
|
||||
const result = await comp.selectCashier();
|
||||
expect(result.name).toBe("Employee1");
|
||||
expect(result.id).toBe(3);
|
||||
store.setCashier(result);
|
||||
const value = store.getCashier();
|
||||
expect(value.name).toBe("Employee1");
|
||||
expect(value.id).toBe(3);
|
||||
});
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { Navbar } from "@point_of_sale/app/components/navbar/navbar";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("showCreateProductButtonWithAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const comp = await mountWithCleanup(Navbar, {});
|
||||
expect(comp.showCreateProductButton).toBe(true);
|
||||
});
|
||||
|
||||
test("showCreateProductButtonWithNonAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
const comp = await mountWithCleanup(Navbar, {});
|
||||
expect(comp.showCreateProductButton).toBe(false);
|
||||
});
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { CashMovePopup } from "@point_of_sale/app/components/popups/cash_move_popup/cash_move_popup";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("_prepareTryCashInOutPayload", async () => {
|
||||
await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashMovePopup, {
|
||||
props: { close: () => {} },
|
||||
});
|
||||
const result = comp._prepareTryCashInOutPayload();
|
||||
const employee_id = result[result.length - 1].employee_id;
|
||||
expect(employee_id).toBe(2);
|
||||
});
|
||||
test("partnerId", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(CashMovePopup, {
|
||||
props: { close: () => {} },
|
||||
});
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
expect(comp.partnerId).toBe(emp.work_contact_id.id);
|
||||
});
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { ProductInfoPopup } from "@point_of_sale/app/components/popups/product_info_popup/product_info_popup";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("allowProductEdition", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const product = store.models["product.template"].get(5);
|
||||
const info = await store.getProductInfo(product, 1);
|
||||
const comp = await mountWithCleanup(ProductInfoPopup, {
|
||||
props: {
|
||||
productTemplate: product,
|
||||
info,
|
||||
close: () => {},
|
||||
},
|
||||
});
|
||||
expect(comp.allowProductEdition).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(comp.allowProductEdition).toBe(false);
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import { test, expect, describe } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { LoginScreen } from "@point_of_sale/app/screens/login_screen/login_screen";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
describe("pos_login_screen.js", () => {
|
||||
test("openRegister", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const comp = await mountWithCleanup(LoginScreen, {});
|
||||
comp.openRegister();
|
||||
expect(store.login).toBe(true);
|
||||
});
|
||||
test("backBtnName", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.login = true;
|
||||
const comp = await mountWithCleanup(LoginScreen, {});
|
||||
expect(comp.backBtnName).toBe("Discard");
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { PaymentScreen } from "@point_of_sale/app/screens/payment_screen/payment_screen";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("validateOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const orderUuid = store.getOrder().uuid;
|
||||
const comp = await mountWithCleanup(PaymentScreen, {
|
||||
props: { orderUuid },
|
||||
});
|
||||
await comp.validateOrder();
|
||||
const order = store.getOrder();
|
||||
expect(order.employee_id.id).toBe(2);
|
||||
});
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { hootPosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
import { models } from "@web/../tests/web_test_helpers";
|
||||
|
||||
export class HrEmployee extends models.ServerModel {
|
||||
_name = "hr.employee";
|
||||
|
||||
_load_pos_data_fields() {
|
||||
return ["name", "user_id", "work_contact_id"];
|
||||
}
|
||||
|
||||
_records = [
|
||||
{
|
||||
id: 2,
|
||||
name: "Administrator",
|
||||
user_id: 2,
|
||||
work_contact_id: 3,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Employee1",
|
||||
user_id: 3,
|
||||
work_contact_id: 3,
|
||||
},
|
||||
];
|
||||
|
||||
_load_pos_data_read(records) {
|
||||
records.forEach((emp) => {
|
||||
if (emp.id === 2) {
|
||||
emp._role = "manager";
|
||||
} else {
|
||||
emp._role = "cashier";
|
||||
}
|
||||
});
|
||||
return records;
|
||||
}
|
||||
}
|
||||
patch(hootPosModels, [...hootPosModels, HrEmployee]);
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import { PosConfig } from "@point_of_sale/../tests/unit/data/pos_config.data";
|
||||
|
||||
PosConfig._records = PosConfig._records.map((record) => ({
|
||||
...record,
|
||||
module_pos_hr: true,
|
||||
}));
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosOrder } from "@point_of_sale/app/models/pos_order";
|
||||
|
||||
patch(PosOrder.prototype, {
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosPayment } from "@point_of_sale/../tests/unit/data/pos_payment.data";
|
||||
|
||||
patch(PosPayment.prototype, {
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import { patch } from "@web/core/utils/patch";
|
||||
import { PosSession } from "@point_of_sale/../tests/unit/data/pos_session.data";
|
||||
|
||||
patch(PosSession.prototype, {
|
||||
_load_pos_data_models() {
|
||||
return [...super._load_pos_data_models(), "hr.employee"];
|
||||
},
|
||||
_load_pos_data_fields() {
|
||||
return [...super._load_pos_data_fields(), "employee_id"];
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("getCashierName", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
const posOrder = store.getOrder();
|
||||
expect(posOrder.getCashierName()).toBe("Employee1");
|
||||
});
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
import { test, expect } from "@odoo/hoot";
|
||||
import { setupPosEnv } from "@point_of_sale/../tests/unit/utils";
|
||||
import { definePosModels } from "@point_of_sale/../tests/unit/data/generate_model_definitions";
|
||||
import { patchWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
|
||||
definePosModels();
|
||||
|
||||
test("createNewOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const order = store.getOrder();
|
||||
expect(order.employee_id.id).toBe(2);
|
||||
});
|
||||
test("employeeIsAdmin", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
expect(store.employeeIsAdmin).toBe(true);
|
||||
});
|
||||
test("_getConnectedCashier", async () => {
|
||||
const store = await setupPosEnv();
|
||||
expect(store._getConnectedCashier().id).toBe(2);
|
||||
});
|
||||
test("shouldShowOpeningControl", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const emp = store.models["hr.employee"].get(2);
|
||||
store.setCashier(emp);
|
||||
store.hasLoggedIn = true;
|
||||
expect(store.shouldShowOpeningControl()).toBe(true);
|
||||
});
|
||||
test("allowProductCreation", async () => {
|
||||
const store = await setupPosEnv();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
expect(await store.allowProductCreation()).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(await store.allowProductCreation()).toBe(false);
|
||||
});
|
||||
test("addLineToCurrentOrder", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
const product_id = store.models["product.product"].get(5);
|
||||
const result = await store.addLineToCurrentOrder({
|
||||
product_id: product_id,
|
||||
product_tmpl_id: product_id.product_tmpl_id,
|
||||
});
|
||||
expect(result.order_id.employee_id.id).toBe(2);
|
||||
});
|
||||
test("canEditPayment", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.addNewOrder();
|
||||
const order = store.getOrder();
|
||||
const admin = store.models["hr.employee"].get(2);
|
||||
store.setCashier(admin);
|
||||
expect(store.canEditPayment(order)).toBe(true);
|
||||
const emp = store.models["hr.employee"].get(3);
|
||||
store.setCashier(emp);
|
||||
expect(store.canEditPayment(order)).toBe(false);
|
||||
});
|
||||
test("handleUrlParams prevents unauthorized access when POS is locked with pos_hr", async () => {
|
||||
const store = await setupPosEnv();
|
||||
store.config.module_pos_hr = true;
|
||||
odoo.from_backend = false;
|
||||
|
||||
store.resetCashier();
|
||||
expect(store.cashier).toBe(false);
|
||||
expect(store.config.module_pos_hr).toBe(true);
|
||||
store.router.state.current = "ProductScreen";
|
||||
store.router.state.params = {};
|
||||
|
||||
let navigateCalledWithLoginScreen = false;
|
||||
patchWithCleanup(store.router, {
|
||||
navigate(routeName, routeParams) {
|
||||
if (routeName === "LoginScreen") {
|
||||
navigateCalledWithLoginScreen = true;
|
||||
}
|
||||
return super.navigate(routeName, routeParams);
|
||||
},
|
||||
});
|
||||
|
||||
await store.handleUrlParams();
|
||||
expect(navigateCalledWithLoginScreen).toBe(true);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue