Browse Source

Mar 7 :[UPDT] Updated 'pos_product_stock'

pull/346/merge
AjmalCybro 2 months ago
parent
commit
c0d59d726c
  1. 2
      pos_product_stock/__manifest__.py
  2. 6
      pos_product_stock/doc/RELEASE_NOTES.md
  3. 2
      pos_product_stock/models/__init__.py
  4. 9
      pos_product_stock/models/res_config_settings.py
  5. 9
      pos_product_stock/models/stock_move_line.py
  6. 11
      pos_product_stock/static/src/js/deny_order.js
  7. 21
      pos_product_stock/static/src/js/pos_location.js

2
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",

6
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

2
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

9
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

9
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

11
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);
}

21
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 {

Loading…
Cancel
Save