fix: do not reset asset_category (#29696)
This commit is contained in:
parent
2bcddab553
commit
5193a63781
@ -165,21 +165,21 @@ frappe.ui.form.on("Item", {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -50,15 +50,7 @@ class DataValidationError(frappe.ValidationError):
|
||||
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 @@ def get_uom_conv_factor(uom, stock_uom):
|
||||
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 @@ def get_uom_conv_factor(uom, stock_uom):
|
||||
|
||||
# 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 @@ def validate_item_default_company_links(item_defaults: List[ItemDefault]) -> Non
|
||||
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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user