Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: patches #2

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"field_order": [
"schedule_date",
"depreciation_amount",
"finance_book_id",
"column_break_3",
"accumulated_depreciation_amount",
"journal_entry",
Expand Down Expand Up @@ -64,11 +65,19 @@
"fieldtype": "Link",
"label": "Shift",
"options": "Asset Shift Factor"
},
{
"fieldname": "finance_book_id",
"fieldtype": "Int",
"hidden": 1,
"label": "Finance Book Id",
"print_hide": 1,
"read_only": 1
}
],
"istable": 1,
"links": [],
"modified": "2024-03-27 13:06:51.227001",
"modified": "2024-08-01 17:27:38.205287",
"modified_by": "Administrator",
"module": "Asset",
"name": "Depreciation Schedule",
Expand Down
105 changes: 105 additions & 0 deletions asset/asset/form_tour/item/item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"creation": "2021-08-24 17:56:40.754909",
"docstatus": 0,
"doctype": "Form Tour",
"first_document": 0,
"idx": 0,
"include_name_field": 0,
"is_standard": 1,
"modified": "2021-11-24 17:59:44.559001",
"modified_by": "Administrator",
"module": "Asset",
"name": "Item",
"owner": "Administrator",
"reference_doctype": "Item",
"save_on_complete": 1,
"steps": [
{
"description": "Enter code for Asset Item",
"field": "",
"fieldname": "item_code",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Item Code",
"parent_field": "",
"position": "Bottom",
"title": "Asset Item Code"
},
{
"description": "Enter name for Asset Item",
"field": "",
"fieldname": "item_name",
"fieldtype": "Data",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Item Name",
"parent_field": "",
"position": "Bottom",
"title": "Asset Item Name"
},
{
"description": "Select an Item Group",
"field": "",
"fieldname": "item_group",
"fieldtype": "Link",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Item Group",
"parent_field": "",
"position": "Right",
"title": "Item Group"
},
{
"description": "Check this field to make this an Asset Item",
"field": "",
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"has_next_condition": 1,
"is_table_field": 0,
"label": "Is Fixed Asset",
"next_step_condition": "eval:doc.is_fixed_asset",
"parent_field": "",
"position": "Bottom",
"title": "Is this a Fixed Asset?"
},
{
"description": "On checking it, the system will create an Asset automatically on purchase",
"field": "",
"fieldname": "auto_create_assets",
"fieldtype": "Check",
"has_next_condition": 1,
"is_table_field": 0,
"label": "Auto Create Assets on Purchase",
"next_step_condition": "eval:doc.auto_create_assets",
"parent_field": "",
"position": "Bottom",
"title": "Auto Create Asset on Purchase"
},
{
"description": "Select an Asset Category for this Asset Item",
"field": "",
"fieldname": "asset_category",
"fieldtype": "Link",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Asset Category",
"parent_field": "",
"position": "Left",
"title": "Asset Category"
},
{
"description": "Select a naming series which will be used to create an Asset automatically",
"field": "",
"fieldname": "asset_naming_series",
"fieldtype": "Select",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Asset Naming Series",
"parent_field": "",
"position": "Left",
"title": "Asset Naming Series"
}
],
"title": "Item"
}
41 changes: 41 additions & 0 deletions asset/asset/form_tour/purchase_receipt/purchase_receipt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"creation": "2021-08-24 13:03:21.333088",
"docstatus": 0,
"doctype": "Form Tour",
"idx": 0,
"is_standard": 1,
"modified": "2021-08-24 13:03:21.333088",
"modified_by": "Administrator",
"module": "Asset",
"name": "Purchase Receipt",
"owner": "Administrator",
"reference_doctype": "Purchase Receipt",
"save_on_complete": 0,
"steps": [
{
"description": "Select Asset Supplier",
"field": "",
"fieldname": "supplier",
"fieldtype": "Link",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Supplier",
"parent_field": "",
"position": "Bottom",
"title": "Supplier"
},
{
"description": "Select an Asset Item, Enter rate and quantity",
"field": "",
"fieldname": "items",
"fieldtype": "Table",
"has_next_condition": 0,
"is_table_field": 0,
"label": "Items",
"parent_field": "",
"position": "Bottom",
"title": "Items"
}
],
"title": "Purchase Receipt"
}

This file was deleted.

2 changes: 1 addition & 1 deletion asset/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def after_install():
print("Setting up Frappe Asset...")
setup()

click.secho("Thank you for installing Frappe Asset!", fg="green")
click.secho("Thank you for installing Frappe Fixed Asset!", fg="green")

except Exception as e:
click.secho(
Expand Down
16 changes: 13 additions & 3 deletions asset/patches.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[pre_model_sync]
# Patches added in this section will be executed before doctypes are migrated
# Read docs to understand patches: https://frappeframework.com/docs/v14/user/en/database-migrations

[post_model_sync]
# Patches added in this section will be executed after doctypes are migrated
asset.patches.v15_0.correct_asset_value_if_je_with_workflow
asset.patches.v15_0.create_asset_depreciation_schedules_from_assets
asset.patches.v15_0.delete_orphaned_asset_movement_item_records
asset.patches.v15_0.remove_cancelled_asset_capitalization_from_asset
asset.patches.v15_0.rename_daily_depreciation_to_depreciation_amount_based_on_num_days_in_month
asset.patches.v15_0.rename_depreciation_amount_based_on_num_days_in_month_to_daily_prorata_based
asset.patches.v15_0.rename_number_of_depreciations_booked_to_opening_booked_depreciations
asset.patches.v15_0.rename_purchase_receipt_amount_to_purchase_amount
asset.patches.v15_0.update_asset_repair_field_in_stock_entry
asset.patches.v15_0.update_asset_value_for_manual_depr_entries
asset.patches.v15_0.update_gpa_and_ndb_for_assdeprsch
asset.patches.v15_0.update_total_number_of_booked_depreciations
asset.patches.v15_0.update_warehouse_field_in_asset_repair_consumed_item_doctype
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_field


def execute():
accounting_dimensions = frappe.db.get_all(
"Accounting Dimension", fields=["fieldname", "label", "document_type", "disabled"]
)

if not accounting_dimensions:
return

doctype = "Asset Capitalization"

for d in accounting_dimensions:
field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname})

if field:
continue

df = {
"fieldname": d.fieldname,
"label": d.label,
"fieldtype": "Link",
"options": d.document_type,
"insert_after": "accounting_dimensions_section",
}

create_custom_field(doctype, df, ignore_validate=True)

frappe.clear_cache(doctype=doctype)
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ def execute():

frappe.reload_doc("asset", "doctype", "linked_location")

if not frappe.db.table_exists("Crop Cycle"):
frappe.reload_doc("agriculture", "doctype", "crop_cycle")

# Rename the fields in related doctypes
if "linked_land_unit" in frappe.db.get_table_columns("Crop Cycle"):
rename_field("Crop Cycle", "linked_land_unit", "linked_location")

if "land_unit" in frappe.db.get_table_columns("Linked Location"):
rename_field("Linked Location", "land_unit", "location")

Expand Down
16 changes: 16 additions & 0 deletions asset/patches/post_install/set_cwip_and_delete_asset_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import frappe
from frappe.utils import cint


def execute():
"""Get 'Disable CWIP Accounting value' from Asset Settings, set it in 'Enable Capital Work in Progress Accounting' field
in Company, delete Asset Settings"""

if frappe.db.exists("DocType", "Asset Settings"):
frappe.reload_doctype("Asset Category")
cwip_value = frappe.db.get_single_value("Asset Settings", "disable_cwip_accounting")

frappe.db.sql("""UPDATE `tabAsset Category` SET enable_cwip_accounting = %s""", cint(cwip_value))

frappe.db.sql("""DELETE FROM `tabSingles` where doctype = 'Asset Settings'""")
frappe.delete_doc_if_exists("DocType", "Asset Settings")
8 changes: 8 additions & 0 deletions asset/patches/post_install/update_asset_quantity_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import frappe


def execute():
if frappe.db.count("Asset"):
frappe.reload_doc("assets", "doctype", "Asset")
asset = frappe.qb.DocType("Asset")
frappe.qb.update(asset).set(asset.asset_quantity, 1).run()
17 changes: 17 additions & 0 deletions asset/patches/post_install/update_total_asset_cost_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import frappe


def execute():
asset = frappe.qb.DocType("Asset")
frappe.qb.update(asset).set(asset.total_asset_cost, asset.gross_purchase_amount).run()

asset_repair_list = frappe.db.get_all(
"Asset Repair",
filters={"docstatus": 1, "repair_status": "Completed", "capitalize_repair_cost": 1},
fields=["asset", "repair_cost"],
)

for asset_repair in asset_repair_list:
frappe.qb.update(asset).set(
asset.total_asset_cost, asset.total_asset_cost + asset_repair.repair_cost
).where(asset.name == asset_repair.asset).run()
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import frappe


def execute():
asset = frappe.qb.DocType("Asset")
frappe.qb.update(asset).set(asset.asset_quantity, 1).where(asset.asset_quantity == 0).run()
Loading
Loading