mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-28 07:31:31 +01:00
refactor: updated related references
This commit is contained in:
@@ -208,14 +208,11 @@ class Asset(AccountsController):
|
||||
add_asset_activity(self.name, _("Asset cancelled"))
|
||||
|
||||
def after_insert(self):
|
||||
if (
|
||||
not frappe.db.exists(
|
||||
{
|
||||
"doctype": "Asset Activity",
|
||||
"asset": self.name,
|
||||
}
|
||||
)
|
||||
and not self.flags.asset_created_via_asset_capitalization
|
||||
if not frappe.db.exists(
|
||||
{
|
||||
"doctype": "Asset Activity",
|
||||
"asset": self.name,
|
||||
}
|
||||
):
|
||||
add_asset_activity(self.name, _("Asset created"))
|
||||
|
||||
@@ -1006,7 +1003,6 @@ def create_asset_capitalization(company, asset, asset_name, item_code):
|
||||
{
|
||||
"target_asset": asset,
|
||||
"company": company,
|
||||
"capitalization_method": "Choose a WIP composite asset",
|
||||
"target_asset_name": asset_name,
|
||||
"target_item_code": item_code,
|
||||
}
|
||||
|
||||
@@ -134,10 +134,7 @@ erpnext.assets.AssetCapitalization = class AssetCapitalization extends erpnext.s
|
||||
}
|
||||
|
||||
target_asset() {
|
||||
if (
|
||||
this.frm.doc.target_asset &&
|
||||
this.frm.doc.capitalization_method === "Choose a WIP composite asset"
|
||||
) {
|
||||
if (this.frm.doc.target_asset) {
|
||||
this.set_consumed_stock_items_tagged_to_wip_composite_asset(this.frm.doc.target_asset);
|
||||
this.get_target_asset_details();
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"naming_series",
|
||||
"target_asset",
|
||||
"target_asset_name",
|
||||
"target_asset_location",
|
||||
"target_item_code",
|
||||
"finance_book",
|
||||
"target_qty",
|
||||
@@ -52,13 +51,13 @@
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:(doc.target_item_code && !doc.__islocal && doc.capitalization_method !== 'Choose a WIP composite asset') || doc.capitalization_method=='Create a new composite asset'",
|
||||
"depends_on": "eval:(doc.target_item_code && !doc.__islocal)",
|
||||
"fieldname": "target_item_code",
|
||||
"fieldtype": "Link",
|
||||
"in_standard_filter": 1,
|
||||
"label": "Target Item Code",
|
||||
"mandatory_depends_on": "eval:doc.capitalization_method=='Create a new composite asset'",
|
||||
"options": "Item"
|
||||
"options": "Item",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
@@ -286,20 +285,12 @@
|
||||
"label": "Target Fixed Asset Account",
|
||||
"options": "Account",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.capitalization_method=='Create a new composite asset'",
|
||||
"fieldname": "target_asset_location",
|
||||
"fieldtype": "Link",
|
||||
"label": "Target Asset Location",
|
||||
"mandatory_depends_on": "eval:doc.capitalization_method=='Create a new composite asset'",
|
||||
"options": "Location"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_submittable": 1,
|
||||
"links": [],
|
||||
"modified": "2025-05-20 15:03:47.485193",
|
||||
"modified": "2025-05-20 15:15:12.110035",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Assets",
|
||||
"name": "Asset Capitalization",
|
||||
|
||||
@@ -82,7 +82,6 @@ class AssetCapitalization(StockController):
|
||||
stock_items: DF.Table[AssetCapitalizationStockItem]
|
||||
stock_items_total: DF.Currency
|
||||
target_asset: DF.Link | None
|
||||
target_asset_location: DF.Link | None
|
||||
target_asset_name: DF.Data | None
|
||||
target_batch_no: DF.Link | None
|
||||
target_fixed_asset_account: DF.Link | None
|
||||
@@ -116,7 +115,7 @@ class AssetCapitalization(StockController):
|
||||
|
||||
def before_submit(self):
|
||||
self.validate_source_mandatory()
|
||||
self.create_target_asset()
|
||||
# self.create_target_asset()
|
||||
|
||||
def on_submit(self):
|
||||
self.make_bundle_using_old_serial_batch_fields()
|
||||
@@ -299,16 +298,7 @@ class AssetCapitalization(StockController):
|
||||
d.cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
|
||||
|
||||
def validate_source_mandatory(self):
|
||||
if self.capitalization_method == "Create a new composite asset" and not (
|
||||
self.get("stock_items") or self.get("asset_items")
|
||||
):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Consumed Stock Items or Consumed Asset Items are mandatory for creating new composite asset"
|
||||
)
|
||||
)
|
||||
|
||||
elif not (self.get("stock_items") or self.get("asset_items") or self.get("service_items")):
|
||||
if not (self.get("stock_items") or self.get("asset_items") or self.get("service_items")):
|
||||
frappe.throw(
|
||||
_(
|
||||
"Consumed Stock Items, Consumed Asset Items or Consumed Service Items is mandatory for Capitalization"
|
||||
@@ -557,49 +547,46 @@ class AssetCapitalization(StockController):
|
||||
)
|
||||
)
|
||||
|
||||
def create_target_asset(self):
|
||||
if self.capitalization_method != "Create a new composite asset":
|
||||
return
|
||||
# def create_target_asset(self):
|
||||
# if self.capitalization_method != "Create a new composite asset":
|
||||
# return
|
||||
|
||||
total_target_asset_value = flt(self.total_value, self.precision("total_value"))
|
||||
# total_target_asset_value = flt(self.total_value, self.precision("total_value"))
|
||||
|
||||
asset_doc = frappe.new_doc("Asset")
|
||||
asset_doc.company = self.company
|
||||
asset_doc.item_code = self.target_item_code
|
||||
asset_doc.is_composite_asset = 1
|
||||
asset_doc.location = self.target_asset_location
|
||||
asset_doc.available_for_use_date = self.posting_date
|
||||
asset_doc.purchase_date = self.posting_date
|
||||
asset_doc.gross_purchase_amount = total_target_asset_value
|
||||
asset_doc.purchase_amount = total_target_asset_value
|
||||
asset_doc.flags.ignore_validate = True
|
||||
asset_doc.flags.asset_created_via_asset_capitalization = True
|
||||
asset_doc.insert()
|
||||
# asset_doc = frappe.new_doc("Asset")
|
||||
# asset_doc.company = self.company
|
||||
# asset_doc.item_code = self.target_item_code
|
||||
# asset_doc.is_composite_asset = 1
|
||||
# asset_doc.location = self.target_asset_location
|
||||
# asset_doc.available_for_use_date = self.posting_date
|
||||
# asset_doc.purchase_date = self.posting_date
|
||||
# asset_doc.gross_purchase_amount = total_target_asset_value
|
||||
# asset_doc.purchase_amount = total_target_asset_value
|
||||
# asset_doc.flags.ignore_validate = True
|
||||
# asset_doc.flags.asset_created_via_asset_capitalization = True
|
||||
# asset_doc.insert()
|
||||
|
||||
self.target_asset = asset_doc.name
|
||||
# self.target_asset = asset_doc.name
|
||||
|
||||
self.target_fixed_asset_account = get_asset_category_account(
|
||||
"fixed_asset_account", item=self.target_item_code, company=asset_doc.company
|
||||
)
|
||||
asset_doc.set_status("Work In Progress")
|
||||
# self.target_fixed_asset_account = get_asset_category_account(
|
||||
# "fixed_asset_account", item=self.target_item_code, company=asset_doc.company
|
||||
# )
|
||||
# asset_doc.set_status("Work In Progress")
|
||||
|
||||
add_asset_activity(
|
||||
asset_doc.name,
|
||||
_("Asset created after Asset Capitalization {0} was submitted").format(
|
||||
get_link_to_form("Asset Capitalization", self.name)
|
||||
),
|
||||
)
|
||||
# add_asset_activity(
|
||||
# asset_doc.name,
|
||||
# _("Asset created after Asset Capitalization {0} was submitted").format(
|
||||
# get_link_to_form("Asset Capitalization", self.name)
|
||||
# ),
|
||||
# )
|
||||
|
||||
frappe.msgprint(
|
||||
_("Asset {0} has been created. Please set the depreciation details if any and submit it.").format(
|
||||
get_link_to_form("Asset", asset_doc.name)
|
||||
)
|
||||
)
|
||||
# frappe.msgprint(
|
||||
# _("Asset {0} has been created. Please set the depreciation details if any and submit it.").format(
|
||||
# get_link_to_form("Asset", asset_doc.name)
|
||||
# )
|
||||
# )
|
||||
|
||||
def update_target_asset(self):
|
||||
if self.capitalization_method != "Choose a WIP composite asset":
|
||||
return
|
||||
|
||||
total_target_asset_value = flt(self.total_value, self.precision("total_value"))
|
||||
asset_doc = frappe.get_doc("Asset", self.target_asset)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user