Browse Source

Nov 04: [FIX] Bug Fixed 'pos_restrict_product_stock'

pull/347/head
Cybrosys Technologies 6 months ago
parent
commit
20404bd856
  1. 3
      pos_restrict_product_stock/__manifest__.py
  2. 6
      pos_restrict_product_stock/doc/RELEASE_NOTES.md
  3. 35
      pos_restrict_product_stock/static/src/js/OrderScreen.js
  4. 4
      pos_restrict_product_stock/static/src/js/RestrictStockPopup.js

3
pos_restrict_product_stock/__manifest__.py

@ -20,7 +20,7 @@
#############################################################################
{
'name': 'Display Stock in POS | Restrict Out-of-Stock Products in POS',
'version': '17.0.1.0.0',
'version': '17.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""",
@ -37,6 +37,7 @@
'point_of_sale._assets_pos': [
'/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/OrderScreen.js',
'/pos_restrict_product_stock/static/src/css/display_stock.css',
'/pos_restrict_product_stock/static/src/xml/ProductItem.xml',
'/pos_restrict_product_stock/static/src/xml/RestrictStockPopup.xml',

6
pos_restrict_product_stock/doc/RELEASE_NOTES.md

@ -4,3 +4,9 @@
#### Version 17.0.1.0.0
#### ADD
- Initial Commit for Display Stock in POS | Restrict Out-of-Stock Products in POS
#### 30.10.2024
#### Version 17.0.2.1.1
#### 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.

35
pos_restrict_product_stock/static/src/js/OrderScreen.js

@ -0,0 +1,35 @@
/** @odoo-module */
import { Order } from "@point_of_sale/app/store/models";
import { patch } from "@web/core/utils/patch";
import RestrictStockPopup from "@pos_restrict_product_stock/js/RestrictStockPopup"
patch(Order.prototype, {
async pay() {
var type = this.pos.config.stock_type
const pay = true
const body = []
const pro_id = false
for (const line of this.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.pos.popup.add(RestrictStockPopup, {
body: body,
pro_id: pro_id
});
if (confirmed == true) {
return super.pay(); // Proceed with payment
} else {
return ;
}
} else {
return super.pay(); // No restrictions, proceed with payment
}
}
})

4
pos_restrict_product_stock/static/src/js/RestrictStockPopup.js

@ -7,8 +7,12 @@ import { AbstractAwaitablePopup } from "@point_of_sale/app/popup/abstract_awaita
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.services.pos.db.get_product_by_id(this.props.pro_id)
product.order_status = True
this.env.services.pos.selectedOrder.add_product(product);
}
this.props.resolve(true);
this.cancel();
}
}

Loading…
Cancel
Save