fix: do not reset asset_category (#29696)
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index ffea9c2..9e8b3bd 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -165,21 +165,21 @@
frm.set_value('has_batch_no', 0);
frm.toggle_enable(['has_serial_no', 'serial_no_series'], !frm.doc.is_fixed_asset);
- frm.call({
- method: "set_asset_naming_series",
- doc: frm.doc,
- callback: function() {
+ frappe.call({
+ method: "erpnext.stock.doctype.item.item.get_asset_naming_series",
+ callback: function(r) {
frm.set_value("is_stock_item", frm.doc.is_fixed_asset ? 0 : 1);
- frm.trigger("set_asset_naming_series");
+ frm.events.set_asset_naming_series(frm, r.message);
}
});
frm.trigger('auto_create_assets');
},
- set_asset_naming_series: function(frm) {
- if (frm.doc.__onload && frm.doc.__onload.asset_naming_series) {
- frm.set_df_property("asset_naming_series", "options", frm.doc.__onload.asset_naming_series);
+ set_asset_naming_series: function(frm, asset_naming_series) {
+ if ((frm.doc.__onload && frm.doc.__onload.asset_naming_series) || asset_naming_series) {
+ let naming_series = (frm.doc.__onload && frm.doc.__onload.asset_naming_series) || asset_naming_series;
+ frm.set_df_property("asset_naming_series", "options", naming_series);
}
},
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 494fb3b..32c72fd 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -50,15 +50,7 @@
class Item(Document):
def onload(self):
self.set_onload('stock_exists', self.stock_ledger_created())
- self.set_asset_naming_series()
-
- @frappe.whitelist()
- def set_asset_naming_series(self):
- if not hasattr(self, '_asset_naming_series'):
- from erpnext.assets.doctype.asset.asset import get_asset_naming_series
- self._asset_naming_series = get_asset_naming_series()
-
- self.set_onload('asset_naming_series', self._asset_naming_series)
+ self.set_onload('asset_naming_series', get_asset_naming_series())
def autoname(self):
if frappe.db.get_default("item_naming_by") == "Naming Series":
@@ -999,7 +991,7 @@
if uom == stock_uom:
return 1.0
- from_uom, to_uom = uom, stock_uom # renaming for readability
+ from_uom, to_uom = uom, stock_uom # renaming for readability
exact_match = frappe.db.get_value("UOM Conversion Factor", {"to_uom": to_uom, "from_uom": from_uom}, ["value"], as_dict=1)
if exact_match:
@@ -1011,9 +1003,9 @@
# This attempts to try and get conversion from intermediate UOM.
# case:
- # g -> mg = 1000
- # g -> kg = 0.001
- # therefore kg -> mg = 1000 / 0.001 = 1,000,000
+ # g -> mg = 1000
+ # g -> kg = 0.001
+ # therefore kg -> mg = 1000 / 0.001 = 1,000,000
intermediate_match = frappe.db.sql("""
select (first.value / second.value) as value
from `tabUOM Conversion Factor` first
@@ -1072,3 +1064,11 @@
frappe.bold(item_default.company),
frappe.bold(frappe.unscrub(field))
), title=_("Invalid Item Defaults"))
+
+
+@frappe.whitelist()
+def get_asset_naming_series():
+ from erpnext.assets.doctype.asset.asset import get_asset_naming_series
+
+ return get_asset_naming_series()
+