mirror of
https://github.com/bringout/oca-ocb-pos.git
synced 2026-04-22 22:42:04 +02:00
19.0 vanilla
This commit is contained in:
parent
6e54c1af6c
commit
3ca647e428
1087 changed files with 132065 additions and 108499 deletions
|
|
@ -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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue