fix: remove set_only_once from is_fixed_asset

This commit is contained in:
ravibharathi656
2025-12-04 09:17:32 +05:30
parent 6515bb04bf
commit 70521fb9bf
3 changed files with 8 additions and 6 deletions

View File

@@ -230,7 +230,7 @@ frappe.ui.form.on("Item", {
].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

@@ -247,8 +247,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,
@@ -917,7 +916,7 @@
"image_field": "image",
"links": [],
"make_attachments_public": 1,
"modified": "2025-11-03 17:01:24.555003",
"modified": "2025-12-04 09:11:56.029567",
"modified_by": "Administrator",
"module": "Stock",
"name": "Item",

View File

@@ -156,6 +156,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":
@@ -308,8 +309,7 @@ class Item(Document):
frappe.throw(_("Cannot be a fixed asset item as Stock Ledger is created."))
if not self.is_fixed_asset and not self.is_new():
asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
if asset:
if self.has_submitted_assets():
frappe.throw(
_('"Is Fixed Asset" cannot be unchecked, as Asset record exists against the item')
)
@@ -524,6 +524,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):
if self.is_new():
return