fix: set default asset quantity as 1 [dev] (#38223) * fix: make default asset quantity as 1 * fix: get rate_of_depreciation from asset category for asset auto-creation * chore: create asset depr schedules on PR submit, not asset submit * fix: set default asset quantity as 1 * chore: move patch from v15 to v14 (cherry picked from commit 9903049c7ac7310ca9e3f69c30dc355c2e13bfd5) Co-authored-by: Anand Baburajan <anandbaburajan@gmail.com>
This commit is contained in:
parent
491e9b4fd5
commit
99bf63ec0f
@ -481,6 +481,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "1",
|
||||||
"fieldname": "asset_quantity",
|
"fieldname": "asset_quantity",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Asset Quantity",
|
"label": "Asset Quantity",
|
||||||
@ -571,7 +572,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2023-11-15 17:40:17.315203",
|
"modified": "2023-11-20 20:57:37.010467",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@ -46,12 +46,28 @@ class Asset(AccountsController):
|
|||||||
self.validate_item()
|
self.validate_item()
|
||||||
self.validate_cost_center()
|
self.validate_cost_center()
|
||||||
self.set_missing_values()
|
self.set_missing_values()
|
||||||
self.validate_finance_books()
|
|
||||||
if not self.split_from:
|
|
||||||
self.prepare_depreciation_data()
|
|
||||||
update_draft_asset_depr_schedules(self)
|
|
||||||
self.validate_gross_and_purchase_amount()
|
self.validate_gross_and_purchase_amount()
|
||||||
self.validate_expected_value_after_useful_life()
|
self.validate_expected_value_after_useful_life()
|
||||||
|
self.validate_finance_books()
|
||||||
|
|
||||||
|
if not self.split_from:
|
||||||
|
self.prepare_depreciation_data()
|
||||||
|
|
||||||
|
if self.calculate_depreciation:
|
||||||
|
update_draft_asset_depr_schedules(self)
|
||||||
|
|
||||||
|
if frappe.db.exists("Asset", self.name):
|
||||||
|
asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self)
|
||||||
|
|
||||||
|
if asset_depr_schedules_names:
|
||||||
|
asset_depr_schedules_links = get_comma_separated_links(
|
||||||
|
asset_depr_schedules_names, "Asset Depreciation Schedule"
|
||||||
|
)
|
||||||
|
frappe.msgprint(
|
||||||
|
_(
|
||||||
|
"Asset Depreciation Schedules created:<br>{0}<br><br>Please check, edit if needed, and submit the Asset."
|
||||||
|
).format(asset_depr_schedules_links)
|
||||||
|
)
|
||||||
|
|
||||||
self.status = self.get_status()
|
self.status = self.get_status()
|
||||||
|
|
||||||
@ -61,17 +77,7 @@ class Asset(AccountsController):
|
|||||||
if not self.booked_fixed_asset and self.validate_make_gl_entry():
|
if not self.booked_fixed_asset and self.validate_make_gl_entry():
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
if self.calculate_depreciation and not self.split_from:
|
if self.calculate_depreciation and not self.split_from:
|
||||||
asset_depr_schedules_names = make_draft_asset_depr_schedules_if_not_present(self)
|
|
||||||
convert_draft_asset_depr_schedules_into_active(self)
|
convert_draft_asset_depr_schedules_into_active(self)
|
||||||
if asset_depr_schedules_names:
|
|
||||||
asset_depr_schedules_links = get_comma_separated_links(
|
|
||||||
asset_depr_schedules_names, "Asset Depreciation Schedule"
|
|
||||||
)
|
|
||||||
frappe.msgprint(
|
|
||||||
_(
|
|
||||||
"Asset Depreciation Schedules created:<br>{0}<br><br>Please check, edit if needed, and submit the Asset."
|
|
||||||
).format(asset_depr_schedules_links)
|
|
||||||
)
|
|
||||||
self.set_status()
|
self.set_status()
|
||||||
add_asset_activity(self.name, _("Asset submitted"))
|
add_asset_activity(self.name, _("Asset submitted"))
|
||||||
|
|
||||||
@ -823,6 +829,7 @@ def get_item_details(item_code, asset_category, gross_purchase_amount):
|
|||||||
"expected_value_after_useful_life": flt(gross_purchase_amount)
|
"expected_value_after_useful_life": flt(gross_purchase_amount)
|
||||||
* flt(d.salvage_value_percentage / 100),
|
* flt(d.salvage_value_percentage / 100),
|
||||||
"depreciation_start_date": d.depreciation_start_date or nowdate(),
|
"depreciation_start_date": d.depreciation_start_date or nowdate(),
|
||||||
|
"rate_of_depreciation": d.rate_of_depreciation,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -758,7 +758,7 @@ class BuyingController(SubcontractingController):
|
|||||||
"calculate_depreciation": 0,
|
"calculate_depreciation": 0,
|
||||||
"purchase_receipt_amount": purchase_amount,
|
"purchase_receipt_amount": purchase_amount,
|
||||||
"gross_purchase_amount": purchase_amount,
|
"gross_purchase_amount": purchase_amount,
|
||||||
"asset_quantity": row.qty if is_grouped_asset else 0,
|
"asset_quantity": row.qty if is_grouped_asset else 1,
|
||||||
"purchase_receipt": self.name if self.doctype == "Purchase Receipt" else None,
|
"purchase_receipt": self.name if self.doctype == "Purchase Receipt" else None,
|
||||||
"purchase_invoice": self.name if self.doctype == "Purchase Invoice" else None,
|
"purchase_invoice": self.name if self.doctype == "Purchase Invoice" else None,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -350,5 +350,6 @@ erpnext.patches.v15_0.rename_daily_depreciation_to_depreciation_amount_based_on_
|
|||||||
erpnext.patches.v15_0.rename_depreciation_amount_based_on_num_days_in_month_to_daily_prorata_based
|
erpnext.patches.v15_0.rename_depreciation_amount_based_on_num_days_in_month_to_daily_prorata_based
|
||||||
erpnext.patches.v15_0.set_reserved_stock_in_bin
|
erpnext.patches.v15_0.set_reserved_stock_in_bin
|
||||||
erpnext.patches.v14_0.create_accounting_dimensions_in_supplier_quotation
|
erpnext.patches.v14_0.create_accounting_dimensions_in_supplier_quotation
|
||||||
|
erpnext.patches.v14_0.update_zero_asset_quantity_field
|
||||||
# below migration patch should always run last
|
# below migration patch should always run last
|
||||||
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
erpnext.patches.v14_0.migrate_gl_to_payment_ledger
|
||||||
|
|||||||
@ -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…
x
Reference in New Issue
Block a user