Browse Source

Nov 27: [FIX] Bug Fixed 'pos_traceability_validation'

pull/351/merge
Cybrosys Technologies 5 months ago
parent
commit
b028e64ceb
  1. 5
      pos_traceability_validation/doc/RELEASE_NOTES.md
  2. 9
      pos_traceability_validation/models/stock_lot.py
  3. 40
      pos_traceability_validation/static/src/js/pos_orderline.js
  4. 12
      pos_traceability_validation/static/src/js/pos_traceability_validation.js

5
pos_traceability_validation/doc/RELEASE_NOTES.md

@ -4,3 +4,8 @@
#### Version 17.0.1.0.0
#### ADD
- Initial Commit for POS Serial Number Validator
#### 27.11.2024
#### Version 17.0.1.1.1
#### UPDT
- Fixed an issue in the case of validation of a product from a different location.

9
pos_traceability_validation/models/stock_lot.py

@ -41,8 +41,13 @@ class StockLot(models.Model):
return True
@api.model
def get_available_lots_qty_pos(self, product_id, lot_name):
def get_available_lots_qty_pos(self, product_id, lot_names, pos_config_id):
"""Check the max lot quantity of corresponding product."""
pos_config = self.env['pos.config'].browse(pos_config_id)
location_id = pos_config.picking_type_id.default_location_src_id.id
stock_quant = self.env['stock.lot'].search([
('product_id', '=', product_id), ('name', '=', lot_name)])
('product_id', '=', product_id),
('name', '=', lot_names),
('location_id', '=', location_id)
])
return stock_quant.product_qty

40
pos_traceability_validation/static/src/js/pos_orderline.js

@ -14,19 +14,43 @@ patch(Orderline.prototype, {
// Checking the orderline quantity and onhand lot quantity
super.set_quantity(quantity, keep_price);
var lines = await this.get_lot_lines()
var pos_config_id = this.pos.config.id
if(lines.length){
var product_id = this.get_product().id
var lot_name = lines[0].lot_name
var lot_name = lines.map(line => line.lot_name).pop();
const result = await this.pos.orm.call(
"stock.lot", "get_available_lots_qty_pos", [product_id, lot_name], {}
"stock.lot", "get_available_lots_qty_pos", [product_id, lot_name, pos_config_id], {}
)
if (quantity > result) {
this.quantity = result
await this.env.services.popup.add(CustomButtonPopup, {
title: _t("Exception"),
});
browser.location.reload()
if (result != 0 && lines.length == 1) {
if (quantity > result) {
this.quantity = result;
await this.env.services.popup.add(CustomButtonPopup, {
title: _t("Exception"),
body: _t("Product quantity Exceeding the allowed lot quantity")
});
}
} else if (result == 0) {
const order = this.pos.get_order();
const selectedLine = order.get_selected_orderline();
selectedLine.stock = result;
if (quantity === 1 && lines.length >= 1) {
order._unlinkOrderline(selectedLine);
}
else if (quantity >=1) {
const Length = selectedLine.pack_lot_lines.length
const LastLine = selectedLine.pack_lot_lines[Length - 1]
selectedLine.pack_lot_lines.remove(LastLine)
selectedLine.set_quantity(quantity - 1, keep_price)
}
this.env.services.popup.add(ErrorPopup, {
title: _t("No Stock Available"),
body: _t(
"The requested lot:" + lot_name + "is currently out of stock."
),
});
}
}
}
});

12
pos_traceability_validation/static/src/js/pos_traceability_validation.js

@ -19,6 +19,8 @@ patch(EditListPopup.prototype, {
async confirm() {
/**Checking the lot and serial and raising the error popup**/
if (this.props.title === 'Lot/Serial Number(s) Required'){
var pos_config_id = this.pos.config.id
let product_id = this.props.id
var lot_string = this.state.array
var lot_names = [];
for (var i = 0; i < lot_string.length; i++) {
@ -26,9 +28,11 @@ patch(EditListPopup.prototype, {
lot_names.push(lot_string[i].text);
}
}
const result = await this.orm.call(
"stock.lot", "validate_lots", [lot_names], {}
)
const StockStatus = this.pos.get_order()?.get_selected_orderline()?.stock
if(result != true){
if(result[0] == 'no_stock'){
this.env.services.popup.add(ErrorPopup, {
@ -56,6 +60,14 @@ patch(EditListPopup.prototype, {
});
}
}
// else if(StockStatus === 0){
// this.env.services.popup.add(ErrorPopup, {
// title: _t("No Stock Available"),
// body: _t(
// "The requested lot: is currently out of stock."
// ),
// });
// }
else{
this.props.resolve({ confirmed: true, payload: await this.getPayload() });
this.pos.closeTempScreen();

Loading…
Cancel
Save