LaOsaCoop/Odoo16#14 migration pos_customer_required

This commit is contained in:
Luis 2025-05-11 18:40:33 +02:00
parent b062c383d5
commit 08fca37c6d
27 changed files with 1438 additions and 0 deletions

View file

@ -0,0 +1,37 @@
/* Copyright apertoso NV- Jos DE GRAEVE <Jos.DeGraeve@apertoso.be>
Copyright La Louve - Sylvain LE GAL <https://twitter.com/legalsylvain>
Copyright NuoBiT - Eric Antones <eantones@nuobit.com>
Copyright NuoBiT - Kilian Niubo <kniubo@nuobit.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) */
odoo.define("pos_customer_required.PaymentScreen", function (require) {
"use strict";
const PaymentScreen = require("point_of_sale.PaymentScreen");
const Registries = require("point_of_sale.Registries");
const core = require("web.core");
const _t = core._t;
const PosRequiredCustomerPaymentScreen = (PaymentScreen) =>
class extends PaymentScreen {
async _isOrderValid(isForceValidate) {
if (
this.env.pos.config.require_customer === "payment" &&
!this.env.pos.get_order().get_partner()
) {
const result = await this.showPopup("ConfirmPopup", {
title: _t("An anonymous order cannot be confirmed"),
body: _t("Please select a customer for this order."),
});
if (result.confirmed) {
this.selectClient();
}
return false;
}
return super._isOrderValid(isForceValidate);
}
};
Registries.Component.extend(PaymentScreen, PosRequiredCustomerPaymentScreen);
return PosRequiredCustomerPaymentScreen;
});

View file

@ -0,0 +1,38 @@
/** @odoo-module **/
import {Component} from "point_of_sale.Registries";
import ProductScreen from "point_of_sale.ProductScreen";
const { onMounted } = owl;
const PosRequiredCustomerProductScreen = (ProductScreen) =>
class extends ProductScreen {
setup() {
super.setup();
onMounted(async () => {
if (
this.env.pos.config.require_customer === "order" &&
!this.env.pos.get_order().get_partner()
) {
this.onClickPartner();
}
});
}
async _onClickPay() {
if (
(this.env.pos.config.require_customer === "order" ||
this.env.pos.config.require_customer === "payment") &&
!this.env.pos.get_order().get_partner()
) {
this.onClickPartner();
}
else {
return super._onClickPay(...arguments);
}
}
};
Component.extend(ProductScreen, PosRequiredCustomerProductScreen);
export default ProductScreen;