Skip to content

Commit 96cc9e2

Browse files
committed
fix: add Stock UOM when adding new item in POS list (frappe#44780)
1 parent ca7c229 commit 96cc9e2

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

erpnext/selling/page/point_of_sale/pos_controller.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -574,11 +574,19 @@ erpnext.PointOfSale.Controller = class {
574574
} else {
575575
if (!this.frm.doc.customer) return this.raise_customer_selection_alert();
576576

577-
const { item_code, batch_no, serial_no, rate, uom } = item;
577+
const { item_code, batch_no, serial_no, rate, uom, stock_uom } = item;
578578

579579
if (!item_code) return;
580580

581-
const new_item = { item_code, batch_no, rate, uom, [field]: value };
581+
if (rate == undefined || rate == 0) {
582+
frappe.show_alert({
583+
message: __("Price is not set for the item."),
584+
indicator: "orange",
585+
});
586+
frappe.utils.play_sound("error");
587+
return;
588+
}
589+
const new_item = { item_code, batch_no, rate, uom, [field]: value, stock_uom };
582590

583591
if (serial_no) {
584592
await this.check_serial_no_availablilty(item_code, this.frm.doc.set_warehouse, serial_no);

erpnext/selling/page/point_of_sale/pos_item_selector.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ erpnext.PointOfSale.ItemSelector = class {
118118
data-item-code="${escape(item.item_code)}" data-serial-no="${escape(serial_no)}"
119119
data-batch-no="${escape(batch_no)}" data-uom="${escape(uom)}"
120120
data-rate="${escape(price_list_rate || 0)}"
121+
data-stock-uom="${escape(item.stock_uom)}"
121122
title="${item.item_name}">
122123
123124
${get_item_image_html()}
@@ -251,17 +252,19 @@ erpnext.PointOfSale.ItemSelector = class {
251252
let serial_no = unescape($item.attr("data-serial-no"));
252253
let uom = unescape($item.attr("data-uom"));
253254
let rate = unescape($item.attr("data-rate"));
255+
let stock_uom = unescape($item.attr("data-stock-uom"));
254256

255257
// escape(undefined) returns "undefined" then unescape returns "undefined"
256258
batch_no = batch_no === "undefined" ? undefined : batch_no;
257259
serial_no = serial_no === "undefined" ? undefined : serial_no;
258260
uom = uom === "undefined" ? undefined : uom;
259261
rate = rate === "undefined" ? undefined : rate;
262+
stock_uom = stock_uom === "undefined" ? undefined : stock_uom;
260263

261264
me.events.item_selected({
262265
field: "qty",
263266
value: "+1",
264-
item: { item_code, batch_no, serial_no, uom, rate },
267+
item: { item_code, batch_no, serial_no, uom, rate, stock_uom },
265268
});
266269
me.search_field.set_focus();
267270
});

0 commit comments

Comments
 (0)