mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-23 16:48:30 +00:00
Merge pull request #30159 from frappe/mergify/bp/version-13-hotfix/pr-29696
fix: do not reset asset_category (backport #29696)
This commit is contained in:
@@ -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":
|
||||
@@ -1000,7 +992,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:
|
||||
@@ -1012,9 +1004,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
|
||||
@@ -1073,3 +1065,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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user