Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,42 @@
/** @odoo-module **/
// SPDX-FileCopyrightText: 2025 Coop IT Easy SC
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import {Component} from "point_of_sale.Registries";
import PaymentScreen from "point_of_sale.PaymentScreen";
import {useBarcodeReader} from "point_of_sale.custom_hooks";
const MealVoucherPaymentScreen = (OriginalPaymentScreen) =>
class extends OriginalPaymentScreen {
setup() {
super.setup();
if (this.env.pos.paper_meal_voucher_payment_method !== null) {
useBarcodeReader({
meal_voucher_payment: this._barcodeMealVoucherAction,
});
}
}
async _barcodeMealVoucherAction(code) {
return this.currentOrder.handle_meal_voucher_barcode(code);
}
get hasMealVoucherPaymentMethod() {
return this.env.pos.config.has_meal_voucher_payment_method;
}
get mealVoucherEligibleAmount() {
return this.currentOrder.get_total_meal_voucher_eligible();
}
get mealVoucherReceivedAmount() {
return this.currentOrder.get_total_meal_voucher_received();
}
get maxMealVoucherAmount() {
return this.env.pos.config.max_meal_voucher_amount;
}
};
Component.extend(PaymentScreen, MealVoucherPaymentScreen);

View file

@ -0,0 +1,16 @@
/** @odoo-module **/
// SPDX-FileCopyrightText: 2025 Coop IT Easy SC
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import {Component} from "point_of_sale.Registries";
import PaymentScreenPaymentLines from "point_of_sale.PaymentScreenPaymentLines";
const MealVoucherPaymentScreenPaymentLines = (OriginalPaymentScreenPaymentLines) =>
class extends OriginalPaymentScreenPaymentLines {
isMealVoucher(line) {
return line.payment_method.meal_voucher_type !== false;
}
};
Component.extend(PaymentScreenPaymentLines, MealVoucherPaymentScreenPaymentLines);

View file

@ -0,0 +1,19 @@
/** @odoo-module **/
// SPDX-FileCopyrightText: 2025 Coop IT Easy SC
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import {Component} from "point_of_sale.Registries";
import Orderline from "point_of_sale.Orderline";
const MealVoucherOrderline = (OriginalOrderline) =>
class extends OriginalOrderline {
get displayMealVoucherIcon() {
return (
this.env.pos.config.enable_meal_voucher_order_lines_icon &&
this.props.line.get_product().meal_voucher_ok
);
}
};
Component.extend(Orderline, MealVoucherOrderline);

View file

@ -0,0 +1,28 @@
/** @odoo-module **/
// SPDX-FileCopyrightText: 2025 Coop IT Easy SC
//
// SPDX-License-Identifier: AGPL-3.0-or-later
import {Component} from "point_of_sale.Registries";
import ProductScreen from "point_of_sale.ProductScreen";
import {useBarcodeReader} from "point_of_sale.custom_hooks";
const MealVoucherProductScreen = (OriginalProductScreen) =>
class extends OriginalProductScreen {
setup() {
super.setup();
if (this.env.pos.paper_meal_voucher_payment_method !== null) {
useBarcodeReader({
meal_voucher_payment: this._barcodeMealVoucherAction,
});
}
}
async _barcodeMealVoucherAction(code) {
// Display the payment screen, if it is not the current one.
this.showScreen("PaymentScreen");
return this.currentOrder.handle_meal_voucher_barcode(code);
}
};
Component.extend(ProductScreen, MealVoucherProductScreen);

View file

@ -0,0 +1,168 @@
/** @odoo-module **/
// Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
// @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import {Order, Orderline, Payment, PosGlobalState} from "point_of_sale.models";
import {Gui} from "point_of_sale.Gui";
import {Model} from "point_of_sale.Registries";
import {_t} from "web.core";
import {round_precision as round_pr} from "web.utils";
const MealVoucherOrder = (OriginalOrder) =>
class extends OriginalOrder {
get_total_meal_voucher_eligible() {
return round_pr(
this.orderlines.reduce(function (sum, orderLine) {
if (orderLine.product.meal_voucher_ok) {
return sum + orderLine.get_price_with_tax();
}
return sum;
}, 0),
this.pos.currency.rounding
);
}
get_total_meal_voucher_non_eligible() {
return round_pr(
this.orderlines.reduce(function (sum, orderLine) {
if (!orderLine.product.meal_voucher_ok) {
return sum + orderLine.get_price_with_tax();
}
return sum;
}, 0),
this.pos.currency.rounding
);
}
get_total_meal_voucher_received() {
return round_pr(
this.paymentlines.reduce(function (sum, paymentLine) {
if (paymentLine.is_meal_voucher()) {
return sum + paymentLine.get_amount();
}
return sum;
}, 0),
this.pos.currency.rounding
);
}
async _meal_voucher_is_valid(code) {
for (const payment_line of this.paymentlines) {
if (payment_line.payment_note === code) {
await Gui.showPopup("ErrorPopup", {
title: _t("Invalid Meal Voucher"),
body: _.str.sprintf(
_t(
'The paper meal voucher with code "%s" has already been scanned.'
),
code
),
});
return false;
}
}
return true;
}
async handle_meal_voucher_barcode(code) {
if (!(await this._meal_voucher_is_valid(code.code))) {
return;
}
// Add new payment line with the amount found in the barcode.
const payment_line = this.add_paymentline(
this.pos.paper_meal_voucher_payment_method
);
payment_line.set_amount(code.value);
payment_line.payment_note = code.code;
}
};
Model.extend(Order, MealVoucherOrder);
const RECEIPT_ORDER_LINE_PREFIX = "(*) ";
const MealVoucherOrderline = (OriginalOrderline) =>
class extends OriginalOrderline {
generate_wrapped_product_name() {
if (
!this.get_product().meal_voucher_ok ||
!this.pos.config.enable_meal_voucher_receipt_info
) {
return super.generate_wrapped_product_name(...arguments);
}
// Temporarily change the product name to add a prefix on the
// receipt.
//
// .generate_wrapped_product_name() calls
// .get_full_product_name(), and it has a different behavior
// depending on whether this.full_product_name is set or not. both
// behaviors must be handled, because one is used when generating
// a receipt during an order, while the order is used when
// retrieving a receipt from a previous order.
// .get_full_product_name() cannot be overridden because its
// result is also used for display in the product screen and
// its result is stored, which would result in the prefix being
// added each time the pos interface is reloaded.
const originalFullProductName = this.full_product_name;
const originalDisplayName = this.product.display_name;
if (originalFullProductName) {
this.full_product_name =
RECEIPT_ORDER_LINE_PREFIX + originalFullProductName;
} else {
this.product.display_name =
RECEIPT_ORDER_LINE_PREFIX + originalDisplayName;
}
const res = super.generate_wrapped_product_name(...arguments);
if (originalFullProductName) {
this.full_product_name = originalFullProductName;
} else {
this.product.display_name = originalDisplayName;
}
return res;
}
};
Model.extend(Orderline, MealVoucherOrderline);
const MealVoucherPayment = (OriginalPayment) =>
class extends OriginalPayment {
initialize() {
super.initialize(...arguments);
this.payment_note = null;
}
init_from_JSON(json) {
super.init_from_JSON(...arguments);
this.payment_note = json.payment_note;
}
export_as_JSON() {
const res = super.export_as_JSON(...arguments);
res.payment_note = this.payment_note;
return res;
}
is_meal_voucher() {
return this.payment_method.meal_voucher_type !== false;
}
};
Model.extend(Payment, MealVoucherPayment);
const MealVoucherPosGlobalState = (OriginalPosGlobalState) =>
class extends OriginalPosGlobalState {
async load_server_data() {
await super.load_server_data(...arguments);
this.paper_meal_voucher_payment_method = null;
for (const payment_method_id of this.config.payment_method_ids) {
const payment_method = this.payment_methods_by_id[payment_method_id];
if (payment_method.meal_voucher_type === "paper") {
this.paper_meal_voucher_payment_method = payment_method;
break;
}
}
}
};
Model.extend(PosGlobalState, MealVoucherPosGlobalState);

View file

@ -0,0 +1,56 @@
.pos .paymentline .is-meal-voucher {
text-align: center;
padding: map-get($spacers, 3);
}
.pos .paymentline .is-meal-voucher .fa-cutlery {
border-radius: 8px;
border: 1px solid rgba($gray-700, 0.5);
width: 24px;
line-height: 24px;
}
.payment-screen div.meal-voucher-summary .fa-warning {
color: red;
}
.pos .meal-voucher-summary {
// same as .pos .paymentlines
display: flex;
flex-direction: column-reverse;
border-spacing: 0px 10px;
border-collapse: inherit;
}
.pos .meal-voucher-summary-container {
padding: map-get($spacers, 2) 0;
}
.pos .meal-voucher-summary-line {
// same as .pos .paymentline, with some changes
display: flex;
flex-grow: 1;
flex-basis: 100%;
background: #fff;
font-size: 16px;
border-top-width: 0px;
padding: map-get($spacers, 2) 0;
}
.meal-voucher-summary-line .meal-voucher-summary-line-name {
flex-grow: 1;
padding: 0 map-get($spacers, 3);
}
.meal-voucher-summary-line .meal-voucher-summary-line-amount {
padding: 0 map-get($spacers, 3);
}
.meal-voucher-summary-line .meal-voucher-summary-line-warning {
font-size: 20px;
margin-bottom: -(map-get($spacers, 2));
}
.pos-receipt-meal-voucher-totals {
font-size: 75%;
}

View file

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="MealVoucherPaymentScreen"
t-inherit="point_of_sale.PaymentScreen"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//div[hasclass('paymentmethods')]" position="after">
<div t-if="hasMealVoucherPaymentMethod" class="meal-voucher-summary">
<p class="title-category">Meal Vouchers</p>
<div class="meal-voucher-summary-container">
<div class="meal-voucher-summary-line">
<div class="meal-voucher-summary-line-name">Total Eligible</div>
<div
t-if="mealVoucherReceivedAmount > mealVoucherEligibleAmount"
class="meal-voucher-summary-line-warning"
>
<i
id="meal-voucher-eligible-warning"
class="fa fa-warning"
/>
</div>
<div class="meal-voucher-summary-line-amount">
<span
id="meal-voucher-eligible-amount"
t-out="env.pos.format_currency(mealVoucherEligibleAmount)"
/>
</div>
</div>
<div
t-if="maxMealVoucherAmount !== 0"
class="meal-voucher-summary-line"
>
<div class="meal-voucher-summary-line-name">Max Amount</div>
<div
t-if="mealVoucherReceivedAmount > maxMealVoucherAmount"
class="meal-voucher-summary-line-warning"
>
<i id="meal-voucher-max-warning" class="fa fa-warning" />
</div>
<div class="meal-voucher-summary-line-amount">
<span
id="meal-voucher-max-amount"
t-out="env.pos.format_currency(maxMealVoucherAmount)"
/>
</div>
</div>
<div class="meal-voucher-summary-line">
<div class="meal-voucher-summary-line-name">Total Received</div>
<div class="meal-voucher-summary-line-amount">
<span
id="meal-voucher-received-amount"
t-out="env.pos.format_currency(mealVoucherReceivedAmount)"
/>
</div>
</div>
</div>
</div>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="MealVoucherPaymentScreenPaymentLines"
t-inherit="point_of_sale.PaymentScreenPaymentLines"
t-inherit-mode="extension"
owl="1"
>
<xpath
expr="//t[@t-if='line.selected']/div/div[hasclass('payment-amount')]"
position="before"
>
<div t-if="isMealVoucher(line)" class="is-meal-voucher">
<i class="fa fa-cutlery" />
</div>
</xpath>
<xpath
expr="//t[@t-foreach='props.paymentLines']/t[@t-else='']/div/div[hasclass('payment-amount')]"
position="before"
>
<div t-if="isMealVoucher(line)" class="is-meal-voucher">
<i class="fa fa-cutlery" />
</div>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="MealVoucherOrderSummary"
t-inherit="point_of_sale.OrderSummary"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//div[hasclass('summary')][1]" position="after">
<t t-if="env.pos.config.has_meal_voucher_payment_method">
<div class="summary clearfix">
<div class="line">
<div class="subentry meal-voucher">
Meal Voucher: <span
class="value"
t-out="env.pos.format_currency(props.order.get_total_meal_voucher_eligible())"
/>
</div>
</div>
</div>
</t>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="MealVoucherOrderline"
t-inherit="point_of_sale.Orderline"
t-inherit-mode="extension"
owl="1"
>
<!--
the space after the <i> element is needed to separate the icon
from the product name.
-->
<xpath expr="//span[hasclass('product-name')]/t[1]" position="before">
<t t-if="displayMealVoucherIcon"><i class="fa fa-cutlery" /> </t>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t
t-name="MealVoucherOrderReceipt"
t-inherit="point_of_sale.OrderReceipt"
t-inherit-mode="extension"
owl="1"
>
<xpath expr="//t/div[hasclass('pos-receipt-amount')]/.." position="after">
<t t-if="env.pos.config.enable_meal_voucher_receipt_info">
<br />
<div class="pos-receipt-meal-voucher-totals">
Products marked with an asterisk (*) can be paid for by meal vouchers.
<br />
Eligible Total:
<span
t-out="env.pos.format_currency(props.order.get_total_meal_voucher_eligible())"
class="pos-receipt-right-align"
/>
<br />
Non-Eligible Total:
<span
t-out="env.pos.format_currency(props.order.get_total_meal_voucher_non_eligible())"
class="pos-receipt-right-align"
/>
</div>
</t>
</xpath>
</t>
</templates>