diff --git a/pos_pro_cross_selling/__manifest__.py b/pos_pro_cross_selling/__manifest__.py index d408ee64e..34f46b82c 100644 --- a/pos_pro_cross_selling/__manifest__.py +++ b/pos_pro_cross_selling/__manifest__.py @@ -21,7 +21,7 @@ ################################################################################ { 'name': 'POS Cross-Selling', - 'version': '17.0.1.0.0', + 'version': '17.0.1.1.0', 'category': 'Point Of Sale', 'summary': 'Cross Selling products in pos', 'description': "This module is used for cross selling products in pos. " @@ -40,6 +40,7 @@ '/pos_pro_cross_selling/static/src/app/cross_product/cross_product.js', '/pos_pro_cross_selling/static/src/app/cross_product/cross_product.xml', '/pos_pro_cross_selling/static/src/js/ProductItem.js', + '/pos_pro_cross_selling/static/src/js/product_scan.js', '/pos_pro_cross_selling/static/src/scss/cross_product.scss' ] }, diff --git a/pos_pro_cross_selling/doc/RELEASE_NOTES.md b/pos_pro_cross_selling/doc/RELEASE_NOTES.md index 058869239..174f00812 100644 --- a/pos_pro_cross_selling/doc/RELEASE_NOTES.md +++ b/pos_pro_cross_selling/doc/RELEASE_NOTES.md @@ -5,3 +5,9 @@ #### ADD - Initial commit for POS Cross-Selling + +#### 25.10.2024 +#### Version 17.0.1.1.0 +#### UPDT + +- POS Cross-Selling pop up for product scanning \ No newline at end of file diff --git a/pos_pro_cross_selling/static/src/js/ProductItem.js b/pos_pro_cross_selling/static/src/js/ProductItem.js index 4a3edfdc2..1b7a6d13c 100644 --- a/pos_pro_cross_selling/static/src/js/ProductItem.js +++ b/pos_pro_cross_selling/static/src/js/ProductItem.js @@ -1,4 +1,4 @@ -/** @odoo-module **/ +//** @odoo-module **/ import { PosStore } from "@point_of_sale/app/store/pos_store"; import { jsonrpc } from "@web/core/network/rpc_service"; import { patch } from "@web/core/utils/patch"; diff --git a/pos_pro_cross_selling/static/src/js/product_scan.js b/pos_pro_cross_selling/static/src/js/product_scan.js new file mode 100644 index 000000000..fa7b87459 --- /dev/null +++ b/pos_pro_cross_selling/static/src/js/product_scan.js @@ -0,0 +1,58 @@ +/** @odoo-module **/ +import { jsonrpc } from "@web/core/network/rpc_service"; +import { patch } from "@web/core/utils/patch"; +import { CrossProduct } from "@pos_pro_cross_selling/app/cross_product/cross_product"; +import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen"; +import { ErrorBarcodePopup } from "@point_of_sale/app/barcode/error_popup/barcode_error_popup"; + +// Function to get cross-selling products for a given product +async function getCrossSellingProducts(productId) { + const result = await jsonrpc('/web/dataset/call_kw/pos.cross.selling/get_cross_selling_products', { + model: 'pos.cross.selling', + method: 'get_cross_selling_products', + args: [[], productId], + kwargs: {}, + }); + return result; + } +patch(ProductScreen.prototype, { + /** + * @overwrite + */ + async _barcodeProductAction(code) { + const product = await this._getProductByBarcode(code); + if (!product) { + return this.popup.add(ErrorBarcodePopup, { code: code.base_code }); + } + const result = await getCrossSellingProducts(product.id); + if (result.length >0) { + await this.popup.add(CrossProduct, { + product: result + }); + } + const options = await product.getAddProductOptions(code); + if (!options) { + return; + } + if (code.type === "price") { + Object.assign(options, { + price: code.value, + extras: { + price_type: "manual", + }, + }); + } else if (code.type === "weight" || code.type === "quantity") { + Object.assign(options, { + quantity: code.value, + merge: false, + }); + } else if (code.type === "discount") { + Object.assign(options, { + discount: code.value, + merge: false, + }); + } + this.currentOrder.add_product(product, options); + this.numberBuffer.reset(); + } +}); \ No newline at end of file