From c0d59d726ca333873d8c917e56317f41c672e9db Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Wed, 12 Mar 2025 14:44:44 +0530 Subject: [PATCH] Mar 7 :[UPDT] Updated 'pos_product_stock' --- pos_product_stock/__manifest__.py | 2 +- pos_product_stock/doc/RELEASE_NOTES.md | 6 ++++++ pos_product_stock/models/__init__.py | 2 +- .../models/res_config_settings.py | 9 +++++--- pos_product_stock/models/stock_move_line.py | 9 +++++--- pos_product_stock/static/src/js/deny_order.js | 11 +++++++--- .../static/src/js/pos_location.js | 21 +++++++++---------- 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/pos_product_stock/__manifest__.py b/pos_product_stock/__manifest__.py index 022e5c635..6055389db 100644 --- a/pos_product_stock/__manifest__.py +++ b/pos_product_stock/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################# { 'name': 'POS Product Stock', - 'version': "18.0.1.0.0", + 'version': "18.0.1.0.1", 'category': 'Point Of Sale', 'summary': "Quantity of all Products in each Warehouse", 'description': "Shows Stock quantity in POS for all Products in each Warehouse, Odoo 18", diff --git a/pos_product_stock/doc/RELEASE_NOTES.md b/pos_product_stock/doc/RELEASE_NOTES.md index f94c13e33..f706cd7cc 100644 --- a/pos_product_stock/doc/RELEASE_NOTES.md +++ b/pos_product_stock/doc/RELEASE_NOTES.md @@ -4,3 +4,9 @@ #### Version 18.0.1.0.0 #### ADD - Initial Commit for POS Product Stock + +#### 10.03.2025 +#### Version 18.0.1.0.1 +#### UPDT +- Commit for bug fix + diff --git a/pos_product_stock/models/__init__.py b/pos_product_stock/models/__init__.py index 808e679db..6b810296c 100644 --- a/pos_product_stock/models/__init__.py +++ b/pos_product_stock/models/__init__.py @@ -22,6 +22,6 @@ from . import pos_config from . import pos_session from . import product_template -from . import res_config_settings +from . import res_config_settings # remove this from . import stock_move_line from . import stock_quant diff --git a/pos_product_stock/models/res_config_settings.py b/pos_product_stock/models/res_config_settings.py index 4347a4af0..f3e1ee55c 100644 --- a/pos_product_stock/models/res_config_settings.py +++ b/pos_product_stock/models/res_config_settings.py @@ -46,6 +46,9 @@ class ResConfigSettings(models.TransientModel): @api.model def _load_pos_data_fields(self, config_id): """Returns the list of fields to be loaded for POS data.""" - return [ - 'display_stock', 'stock_type', 'stock_from', 'stock_location_id' - ] + result = super()._load_pos_data_fields(config_id) + result.append('display_stock') + result.append('stock_type') + result.append('stock_from') + result.append('stock_location_id') + return result diff --git a/pos_product_stock/models/stock_move_line.py b/pos_product_stock/models/stock_move_line.py index 4f70cdeea..32ed24fd1 100644 --- a/pos_product_stock/models/stock_move_line.py +++ b/pos_product_stock/models/stock_move_line.py @@ -30,6 +30,9 @@ class StockMoveLine(models.Model): @api.model def _load_pos_data_fields(self, config_id): """Returns the list of fields to be loaded for POS data.""" - return [ - 'product_id', 'location_dest_id', 'quantity', 'location_id' - ] + result = super()._load_pos_data_fields(config_id) + result.append('product_id') + result.append('location_dest_id') + result.append('quantity') + result.append('location_id') + return result diff --git a/pos_product_stock/static/src/js/deny_order.js b/pos_product_stock/static/src/js/deny_order.js index 61d45adc3..8a8a4d101 100644 --- a/pos_product_stock/static/src/js/deny_order.js +++ b/pos_product_stock/static/src/js/deny_order.js @@ -15,8 +15,8 @@ patch(ProductScreen.prototype, { const product_product = this.pos.product_product; const stock_product = this.pos.stock_quant; const main_product = product_product.find(product => product.id === current_product_id); - const product_tmpl_id = main_product._raw.product_tmpl_id; - const product_variants = product_product.filter(product => product._raw.product_tmpl_id === product_tmpl_id); + const product_tmpl_id = main_product.raw.product_tmpl_id; + const product_variants = product_product.filter(product => product.raw.product_tmpl_id === product_tmpl_id); let total_qty_available = 0; product_variants.forEach(variant => { stock_product.forEach(stock => { @@ -43,6 +43,7 @@ patch(ProductScreen.prototype, { super.addProductToOrder(event); } }else if (this.pos.res_setting['stock_type'] === 'outgoing_qty') { + if (event.outgoing_qty <= event.deny) { await this.dialog.add(AlertDialog, { title: _t('Deny Order'), @@ -61,7 +62,8 @@ patch(ProductScreen.prototype, { super.addProductToOrder(event); } } - }else if (this.pos.res_setting['stock_from'] ==='current_warehouse') { + } + else if (this.pos.res_setting['stock_from'] ==='current_warehouse') { if (this.pos.res_setting['stock_type'] === 'on_hand') { if (total_qty_available <= event.deny) { await this.dialog.add(AlertDialog, { @@ -91,6 +93,9 @@ patch(ProductScreen.prototype, { } } } + else{ + super.addProductToOrder(event); + } }else { super.addProductToOrder(event); } diff --git a/pos_product_stock/static/src/js/pos_location.js b/pos_product_stock/static/src/js/pos_location.js index d3ce02380..cb31a2cbd 100644 --- a/pos_product_stock/static/src/js/pos_location.js +++ b/pos_product_stock/static/src/js/pos_location.js @@ -4,18 +4,18 @@ import { usePos } from "@point_of_sale/app/store/pos_hook"; import { patch } from "@web/core/utils/patch"; import { useService } from "@web/core/utils/hooks"; import { useRef, useState } from "@odoo/owl"; - patch(ProductCard.prototype, { setup() { super.setup(); + this.pos = usePos(); + this.orm = useService('orm'); this.state = useState({ qty_available: null, incoming_qty: null, outgoing_qty: null, - display_stock: false + display_stock: false, }); - this.pos = usePos(); - this.orm = useService('orm'); + }, async fetchProductDetails(productId) { const product = await this.orm.call("product.product", "read", [[productId], ["name", "id", "incoming_qty","outgoing_qty","qty_available"]]); @@ -28,8 +28,8 @@ patch(ProductCard.prototype, { const product_product = this.pos.product_product; const stock_product = this.pos.stock_quant; const main_product = product_product.find(product => product.id === productId); - const product_tmpl_id = main_product._raw.product_tmpl_id; - const product_variants = product_product.filter(product => product._raw.product_tmpl_id === product_tmpl_id); + const product_tmpl_id = main_product.raw.product_tmpl_id; + const product_variants = product_product.filter(product => product.raw.product_tmpl_id === product_tmpl_id); let total_qty_available = 0; product_variants.forEach((variant) => { if (variant.qty_available) { @@ -51,8 +51,8 @@ patch(ProductCard.prototype, { let outgoing = 0; let incoming = 0; const main_product = product_product.find(product => product.id === current_product); - const product_tmpl_id = main_product._raw.product_tmpl_id; - const product_variants = product_product.filter(product => product._raw.product_tmpl_id === product_tmpl_id); + const product_tmpl_id = main_product.raw.product_tmpl_id; + const product_variants = product_product.filter(product => product.raw.product_tmpl_id === product_tmpl_id); stock_product.forEach((product) => { if (product && product.product_id) { const product_id = product.product_id.id; @@ -65,9 +65,9 @@ patch(ProductCard.prototype, { }); move_line.forEach((line) => { if (line && line.product_id) { - if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting._raw.stock_location_id[1] == line._raw.location_dest_id[1]){ + if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting.raw.stock_location_id[1] == line.raw.location_dest_id[1]){ incoming = incoming + line.product_id.incoming_qty; - }if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting._raw.stock_location_id && this.pos.res_setting._raw.stock_location_id[1] == line._raw.location_id[1]){ + }if(line.product_id.id == current_product && this.pos.res_setting && this.pos.res_setting.raw.stock_location_id && this.pos.res_setting.raw.stock_location_id[1] == line.raw.location_id[1]){ outgoing = outgoing + line.product_id.outgoing_qty; } } @@ -94,7 +94,6 @@ patch(ProductCard.prototype, { this.state.display_stock = true; return { display_stock: this.pos.res_setting.display_stock - }; } else {