Skip to content

Commit

Permalink
Merge pull request #44877 from Abdeali099/backport-uom-handle
Browse files Browse the repository at this point in the history
fix: add `Stock UOM` when adding new item in POS list (#44780)
  • Loading branch information
ruthra-kumar authored Dec 24, 2024
2 parents ca7c229 + 96cc9e2 commit ddc58f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions erpnext/selling/page/point_of_sale/pos_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,19 @@ erpnext.PointOfSale.Controller = class {
} else {
if (!this.frm.doc.customer) return this.raise_customer_selection_alert();

const { item_code, batch_no, serial_no, rate, uom } = item;
const { item_code, batch_no, serial_no, rate, uom, stock_uom } = item;

if (!item_code) return;

const new_item = { item_code, batch_no, rate, uom, [field]: value };
if (rate == undefined || rate == 0) {
frappe.show_alert({
message: __("Price is not set for the item."),
indicator: "orange",
});
frappe.utils.play_sound("error");
return;
}
const new_item = { item_code, batch_no, rate, uom, [field]: value, stock_uom };

if (serial_no) {
await this.check_serial_no_availablilty(item_code, this.frm.doc.set_warehouse, serial_no);
Expand Down
5 changes: 4 additions & 1 deletion erpnext/selling/page/point_of_sale/pos_item_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ erpnext.PointOfSale.ItemSelector = class {
data-item-code="${escape(item.item_code)}" data-serial-no="${escape(serial_no)}"
data-batch-no="${escape(batch_no)}" data-uom="${escape(uom)}"
data-rate="${escape(price_list_rate || 0)}"
data-stock-uom="${escape(item.stock_uom)}"
title="${item.item_name}">
${get_item_image_html()}
Expand Down Expand Up @@ -251,17 +252,19 @@ erpnext.PointOfSale.ItemSelector = class {
let serial_no = unescape($item.attr("data-serial-no"));
let uom = unescape($item.attr("data-uom"));
let rate = unescape($item.attr("data-rate"));
let stock_uom = unescape($item.attr("data-stock-uom"));

// escape(undefined) returns "undefined" then unescape returns "undefined"
batch_no = batch_no === "undefined" ? undefined : batch_no;
serial_no = serial_no === "undefined" ? undefined : serial_no;
uom = uom === "undefined" ? undefined : uom;
rate = rate === "undefined" ? undefined : rate;
stock_uom = stock_uom === "undefined" ? undefined : stock_uom;

me.events.item_selected({
field: "qty",
value: "+1",
item: { item_code, batch_no, serial_no, uom, rate },
item: { item_code, batch_no, serial_no, uom, rate, stock_uom },
});
me.search_field.set_focus();
});
Expand Down

0 comments on commit ddc58f0

Please sign in to comment.