Browse Source

July 18: [FIX] Bug Fixed 'pos_restrict_product_stock'

pull/332/merge
RisvanaCybro 1 year ago
parent
commit
b360d1a3be
  1. 4
      pos_restrict_product_stock/__manifest__.py
  2. 8
      pos_restrict_product_stock/doc/RELEASE_NOTES.md
  3. 10
      pos_restrict_product_stock/models/pos_session.py
  4. 1
      pos_restrict_product_stock/static/src/js/ProductScreen.js
  5. 18
      pos_restrict_product_stock/static/src/js/model.js
  6. 18
      pos_restrict_product_stock/static/src/js/receipt_screen.js
  7. 2
      pos_restrict_product_stock/static/src/xml/ProductItem.xml

4
pos_restrict_product_stock/__manifest__.py

@ -21,7 +21,7 @@
############################################################################### ###############################################################################
{ {
'name': 'Display Stock in POS | Restrict Out-of-Stock Products in POS', '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', 'category': 'Point of Sale',
'summary': "Enhance your Point of Sale experience by preventing the " 'summary': "Enhance your Point of Sale experience by preventing the "
"ordering of out-of-stock products during your session", "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/xml/RestrictStockPopup.xml',
'/pos_restrict_product_stock/static/src/js/RestrictStockPopup.js', '/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/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'], 'images': ['static/description/banner.jpg'],

8
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 #### Version 16.0.1.0.1
#### ADD #### ADD
Code updated that quantity would be shown based on the warehouse in the operation type. Considered the case of Code updated that quantity would be shown based on the warehouse in the operation type. Considered the case of
multiple warehouse 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

10
pos_restrict_product_stock/models/pos_session.py

@ -34,5 +34,15 @@ class PosSession(models.Model):
result = super()._loader_params_product_product() result = super()._loader_params_product_product()
result['search_params']['fields'].append('qty_available') result['search_params']['fields'].append('qty_available')
result['search_params']['fields'].append('virtual_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 result['context']['warehouse'] = self.config_id.picking_type_id.warehouse_id.id
return result 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

1
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 { const RestrictProductScreen = (ProductScreen) => class RestrictProductScreen extends ProductScreen {
async _clickProduct(event) { async _clickProduct(event) {
// Overriding product item click to restrict product out of stock
const product = event.detail; const product = event.detail;
var type = this.env.pos.config.stock_type 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)) | if (this.env.pos.config.is_restrict_product && ((type == 'qty_on_hand') && (product.qty_available <= 0)) | ((type == 'virtual_qty') && (product.virtual_available <= 0)) |

18
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);

18
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);

2
pos_restrict_product_stock/static/src/xml/ProductItem.xml

@ -4,7 +4,7 @@
<t t-name="ProductItem" t-inherit="point_of_sale.ProductItem" <t t-name="ProductItem" t-inherit="point_of_sale.ProductItem"
t-inherit-mode="extension" owl="1"> t-inherit-mode="extension" owl="1">
<xpath expr="//article[hasclass('product')]" position="inside"> <xpath expr="//article[hasclass('product')]" position="inside">
<t t-if="env.pos.config.is_display_stock"> <t t-if="env.pos.config.is_display_stock and props.product.detailed_type != 'service'">
<t t-if="env.pos.config.stock_type == 'qty_on_hand'"> <t t-if="env.pos.config.stock_type == 'qty_on_hand'">
<div t-attf-class="display_qty #{props.product.qty_available lte 0 ? 'not-available':''}" <div t-attf-class="display_qty #{props.product.qty_available lte 0 ? 'not-available':''}"
id="qty_display"> id="qty_display">

Loading…
Cancel
Save