diff --git a/pos_restrict_product_stock/__manifest__.py b/pos_restrict_product_stock/__manifest__.py index 6d93f3477..727d037ff 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.1.0.1', + 'version': '16.0.2.1.1', 'category': 'Point of Sale', 'summary': "Enhance your Point of Sale experience by preventing the " "ordering of out-of-stock products during your session", @@ -42,6 +42,8 @@ '/pos_restrict_product_stock/static/src/xml/RestrictStockPopup.xml', '/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js', '/pos_restrict_product_stock/static/src/js/ProductScreen.js', + '/pos_restrict_product_stock/static/src/js/model.js', + '/pos_restrict_product_stock/static/src/js/receipt_screen.js', ], }, 'images': ['static/description/banner.jpg'], diff --git a/pos_restrict_product_stock/doc/RELEASE_NOTES.md b/pos_restrict_product_stock/doc/RELEASE_NOTES.md index f0bb491bd..a7dedc8b8 100644 --- a/pos_restrict_product_stock/doc/RELEASE_NOTES.md +++ b/pos_restrict_product_stock/doc/RELEASE_NOTES.md @@ -9,4 +9,10 @@ Initial Commit for Display Stock in POS | Restrict Out-of-Stock Products in POS #### Version 16.0.1.0.1 #### ADD Code updated that quantity would be shown based on the warehouse in the operation type. Considered the case of -multiple warehouse \ No newline at end of file +multiple warehouse + +#### 18.07.2024 +#### 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 diff --git a/pos_restrict_product_stock/models/pos_session.py b/pos_restrict_product_stock/models/pos_session.py index 136e247b1..1f7284f25 100644 --- a/pos_restrict_product_stock/models/pos_session.py +++ b/pos_restrict_product_stock/models/pos_session.py @@ -34,5 +34,15 @@ class PosSession(models.Model): result = super()._loader_params_product_product() result['search_params']['fields'].append('qty_available') result['search_params']['fields'].append('virtual_available') + result['search_params']['fields'].append('detailed_type') result['context']['warehouse'] = self.config_id.picking_type_id.warehouse_id.id return result + + def _loader_params_res_company(self): + """Load point_of_sale_update_stock_quantities quantity field to pos session. + :return dict: returns dictionary of field parameters for the + res company model + """ + result = super()._loader_params_res_company() + result['search_params']['fields'].append('point_of_sale_update_stock_quantities') + return result diff --git a/pos_restrict_product_stock/static/src/js/ProductScreen.js b/pos_restrict_product_stock/static/src/js/ProductScreen.js index c2098d9ff..768730a34 100644 --- a/pos_restrict_product_stock/static/src/js/ProductScreen.js +++ b/pos_restrict_product_stock/static/src/js/ProductScreen.js @@ -7,7 +7,6 @@ import ProductScreen from 'point_of_sale.ProductScreen'; const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen extends ProductScreen { async _clickProduct(event) { - // Overriding product item click to restrict product out of stock const product = event.detail; var type = this.env.pos.config.stock_type if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (product.qty_available <= 0)) | ((type == 'virtual_qty') && (product.virtual_available <= 0)) | diff --git a/pos_restrict_product_stock/static/src/js/model.js b/pos_restrict_product_stock/static/src/js/model.js new file mode 100644 index 000000000..93eee2499 --- /dev/null +++ b/pos_restrict_product_stock/static/src/js/model.js @@ -0,0 +1,18 @@ +/** @odoo-module **/ + +import Registries from 'point_of_sale.Registries'; +import { Product } from 'point_of_sale.models'; + +const RestrictProduct = (Product) => class RestrictProduct extends Product { + setQty(qty) { + if (this.detailed_type !== 'service' && + this.pos.config.is_display_stock && + this.pos.company.point_of_sale_update_stock_quantities == 'real') { + this.qty_available -= qty; + this.virtual_available -= qty; + } + } +} + +Registries.Model.extend(Product, RestrictProduct); + diff --git a/pos_restrict_product_stock/static/src/js/receipt_screen.js b/pos_restrict_product_stock/static/src/js/receipt_screen.js new file mode 100644 index 000000000..7c702e44f --- /dev/null +++ b/pos_restrict_product_stock/static/src/js/receipt_screen.js @@ -0,0 +1,18 @@ +/** @odoo-module **/ + +import Registries from 'point_of_sale.Registries'; +import ReceiptScreen from 'point_of_sale.ReceiptScreen'; + +const RestrictReceiptScreen = (ReceiptScreen) => { + class RestrictReceiptScreen extends ReceiptScreen { + async orderDone() { + this.env.pos.get_order().orderlines.forEach(element => { + element.product.setQty(element.quantity); + }); + await super.orderDone(); + } + } + return RestrictReceiptScreen; +}; +Registries.Component.extend(ReceiptScreen, RestrictReceiptScreen); + diff --git a/pos_restrict_product_stock/static/src/xml/ProductItem.xml b/pos_restrict_product_stock/static/src/xml/ProductItem.xml index c4dfbc40d..ef5d9810d 100644 --- a/pos_restrict_product_stock/static/src/xml/ProductItem.xml +++ b/pos_restrict_product_stock/static/src/xml/ProductItem.xml @@ -4,7 +4,7 @@ - +