fix: remove set_only_once from is_fixed_asset

(cherry picked from commit 70521fb9bf)

# Conflicts:
#	erpnext/stock/doctype/item/item.json
#	erpnext/stock/doctype/item/item.py
This commit is contained in:
ravibharathi656
2025-12-04 09:17:32 +05:30
committed by Mergify
parent 8b071c0d22
commit fd6e42e15e
3 changed files with 15 additions and 3 deletions

View File

@@ -224,7 +224,7 @@ frappe.ui.form.on("Item", {
["is_stock_item", "has_serial_no", "has_batch_no", "has_variants"].forEach((fieldname) => {
frm.set_df_property(fieldname, "read_only", stock_exists);
});
frm.set_df_property("is_fixed_asset", "read_only", frm.doc.__onload?.asset_exists ? 1 : 0);
frm.toggle_reqd("customer", frm.doc.is_customer_provided_item ? 1 : 0);
frm.set_query("item_group", () => {
return {

View File

@@ -243,8 +243,7 @@
"default": "0",
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"label": "Is Fixed Asset",
"set_only_once": 1
"label": "Is Fixed Asset"
},
{
"allow_in_quick_entry": 1,
@@ -895,7 +894,11 @@
"image_field": "image",
"links": [],
"make_attachments_public": 1,
<<<<<<< HEAD
"modified": "2025-08-08 14:58:48.674193",
=======
"modified": "2025-12-04 09:11:56.029567",
>>>>>>> 70521fb9bf (fix: remove set_only_once from is_fixed_asset)
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@@ -155,6 +155,7 @@ class Item(Document):
self.set_onload("stock_exists", self.stock_ledger_created())
self.set_onload("asset_naming_series", get_asset_naming_series())
self.set_onload("current_valuation_method", get_valuation_method(self.name))
self.set_onload("asset_exists", self.has_submitted_assets())
def autoname(self):
if frappe.db.get_default("item_naming_by") == "Naming Series":
@@ -306,9 +307,14 @@ class Item(Document):
if self.stock_ledger_created():
frappe.throw(_("Cannot be a fixed asset item as Stock Ledger is created."))
<<<<<<< HEAD
if not self.is_fixed_asset:
asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
if asset:
=======
if not self.is_fixed_asset and not self.is_new():
if self.has_submitted_assets():
>>>>>>> 70521fb9bf (fix: remove set_only_once from is_fixed_asset)
frappe.throw(
_('"Is Fixed Asset" cannot be unchecked, as Asset record exists against the item')
)
@@ -525,6 +531,9 @@ class Item(Document):
)
return self._stock_ledger_created
def has_submitted_assets(self):
return bool(frappe.db.exists("Asset", {"item_code": self.name, "docstatus": 1}))
def update_item_price(self):
frappe.db.sql(
"""