diff --git a/pos_restrict_product_stock/__manifest__.py b/pos_restrict_product_stock/__manifest__.py index 727d037ff..0493b6b1d 100644 --- a/pos_restrict_product_stock/__manifest__.py +++ b/pos_restrict_product_stock/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################### { 'name': 'Display Stock in POS | Restrict Out-of-Stock Products in POS', - 'version': '16.0.2.1.1', + 'version': '16.0.2.2.2', 'category': 'Point of Sale', 'summary': "Enhance your Point of Sale experience by preventing the " "ordering of out-of-stock products during your session", diff --git a/pos_restrict_product_stock/doc/RELEASE_NOTES.md b/pos_restrict_product_stock/doc/RELEASE_NOTES.md index a7dedc8b8..ff0c52e3d 100644 --- a/pos_restrict_product_stock/doc/RELEASE_NOTES.md +++ b/pos_restrict_product_stock/doc/RELEASE_NOTES.md @@ -15,4 +15,10 @@ multiple warehouse #### Version 16.0.2.1.1 #### ADD - Code updated. that quantity and forcast quantity would be updated in real time when a pos order was confirmed when -Also Changed the quantity visible for service product \ No newline at end of file +Also Changed the quantity visible for service product + +#### 11.11.2024 +#### Version 16.0.2.2.2 +#### Update +- Added a new feature that restricts stock availability when clicking the payment button. +This will help prevent the ordering of out-of-stock products, whether entered via barcode or through any other method. \ No newline at end of file diff --git a/pos_restrict_product_stock/static/src/js/ProductScreen.js b/pos_restrict_product_stock/static/src/js/ProductScreen.js index 768730a34..834f22405 100644 --- a/pos_restrict_product_stock/static/src/js/ProductScreen.js +++ b/pos_restrict_product_stock/static/src/js/ProductScreen.js @@ -21,5 +21,31 @@ const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen ext await super._clickProduct(event) } } + async _onClickPay() { + var type = this.env.pos.config.stock_type + const pay = true + const body = [] + const pro_id = false + for (const line of this.env.pos.selectedOrder.orderlines) { + if (line.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (line.product.qty_available <= 0)) | ((type == 'virtual_qty') && (line.product.virtual_available <= 0)) | + ((line.product.qty_available <= 0) && (line.product.virtual_available <= 0))) { + // If the product restriction is activated in the settings and quantity is out stock, it show the restrict popup. + body.push(line.product.display_name) + } + } + if (body.length > 0) { // Check if body has items + const confirmed = await this.showPopup("RestrictStockPopup", { + body: body, + pro_id: pro_id + }); + if (confirmed == true) { + return super._onClickPay(...arguments);// Proceed with payment + } else { + return ; + } + } else { + return super._onClickPay(...arguments); // No restrictions, proceed with payment + } + } } Registries.Component.extend(ProductScreen, RestrictProductScreen); diff --git a/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js b/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js index 6bd7b3e30..e0151345a 100644 --- a/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js +++ b/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js @@ -8,9 +8,12 @@ import Registries from 'point_of_sale.Registries'; class RestrictStockPopup extends AbstractAwaitablePopup { _OrderProduct() { // On clicking order product button on popup, it will add product to orderline + if (this.props.pro_id){ var product = this.env.pos.db.get_product_by_id(this.props.pro_id) this.env.pos.selectedOrder.add_product(product); - this.cancel(); + } + this.props.resolve(true); + this.cancel(); } } RestrictStockPopup.template = 'RestrictStockPopup';