feat: allow to edit Stock Quantity in the Sales and Purchase Transactions (#36600)
feat: allow to edit Stock Quantity in the Sales and Purchase transactions
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 975adc2..b0a9e40 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -224,6 +224,14 @@
}
}
+
+ toggle_enable_for_stock_uom(field) {
+ frappe.db.get_single_value('Stock Settings', field)
+ .then(value => {
+ this.frm.fields_dict["items"].grid.toggle_enable("stock_qty", value);
+ });
+ }
+
onload() {
var me = this;
@@ -1191,6 +1199,16 @@
]);
}
+ stock_qty(doc, cdt, cdn) {
+ let item = frappe.get_doc(cdt, cdn);
+ item.conversion_factor = 1.0;
+ if (item.stock_qty) {
+ item.conversion_factor = flt(item.stock_qty) / flt(item.qty);
+ }
+
+ refresh_field("conversion_factor", item.name, item.parentfield);
+ }
+
calculate_stock_uom_rate(doc, cdt, cdn) {
let item = frappe.get_doc(cdt, cdn);
item.stock_uom_rate = flt(item.rate)/flt(item.conversion_factor);