Code cleanup
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 748849e..55a29bc 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -105,18 +105,18 @@
previous_scheduled_date = add_months(d.depreciation_start_date, (n-1) * 12)
depreciation_amount = \
self.get_depreciation_amount_prorata_temporis(value_after_depreciation,
- row, previous_scheduled_date, schedule_date)
+ d, previous_scheduled_date, schedule_date)
elif n == range(number_of_pending_depreciations)[0]:
schedule_date = d.depreciation_start_date
depreciation_amount = \
self.get_depreciation_amount_prorata_temporis(value_after_depreciation,
- row, self.available_for_use_date, schedule_date)
+ d, self.available_for_use_date, schedule_date)
else:
schedule_date = add_months(d.depreciation_start_date, n * 12)
depreciation_amount = \
- self.get_depreciation_amount_prorata_temporis(value_after_depreciation, row)
+ self.get_depreciation_amount_prorata_temporis(value_after_depreciation, d)
if value_after_depreciation != 0:
value_after_depreciation -= flt(depreciation_amount)
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index c4e9fdd..85fb3f0 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -89,6 +89,9 @@
msgprint(_('Tax Category has been changed to "Total" because all the Items are non-stock items'))
def get_asset_items(self):
+ if self.doctype not in ['Purchase Invoice', 'Purchase Receipt']:
+ return []
+
return [d.item_code for d in self.items if d.is_fixed_asset]
def set_landed_cost_voucher_amount(self):
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2828d77..69b11d6 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -528,4 +528,5 @@
erpnext.patches.v11_0.rename_health_insurance
erpnext.patches.v11_0.rebuild_tree_for_company
erpnext.patches.v11_0.create_department_records_for_each_company
-erpnext.patches.v11_0.make_location_from_warehouse
\ No newline at end of file
+erpnext.patches.v11_0.make_location_from_warehouse
+erpnext.patches.v11_0.make_asset_finance_book_against_old_entries
\ No newline at end of file
diff --git a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
index 75f0ce6..18622f2 100644
--- a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
+++ b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py
@@ -6,31 +6,32 @@
from frappe.utils.nestedset import rebuild_tree
def execute():
- frappe.reload_doc('stock', 'doctype', 'asset_finance_book')
- frappe.reload_doc('stock', 'doctype', 'depreciation_schedule')
+ frappe.reload_doc('assets', 'doctype', 'asset_finance_book')
+ frappe.reload_doc('assets', 'doctype', 'depreciation_schedule')
frappe.reload_doc('assets', 'doctype', 'asset_category')
frappe.reload_doc('assets', 'doctype', 'asset')
frappe.reload_doc('assets', 'doctype', 'asset_movement')
frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh
- set ast.location = wh.warehoue_name where ast.warehoue = wh.name""")
+ set ast.location = wh.warehouse_name where ast.warehouse = wh.name""")
frappe.db.sql(""" update `tabAsset Movement` ast_mv
- set ast_mv.source_location = (select warehoue_name from `tabWarehouse` where name = ast_mv.source_warehouse),
- ast_mv.target_location = (select warehoue_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
+ set ast_mv.source_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.source_warehouse),
+ ast_mv.target_location = (select warehouse_name from `tabWarehouse` where name = ast_mv.target_warehouse)""")
for d in frappe.get_all('Asset'):
doc = frappe.get_doc('Asset', d.name)
- fb = doc.append('finance_books', {
- 'depreciation_method': doc.depreciation_method,
- 'total_number_of_depreciations': doc.total_number_of_depreciations,
- 'frequency_of_depreciation': doc.frequency_of_depreciation,
- 'depreciation_start_date': doc.next_depreciation_date,
- 'expected_value_after_useful_life': doc.expected_value_after_useful_life,
- 'value_after_depreciation': doc.value_after_depreciation
- })
+ if doc.calculate_depreciation:
+ fb = doc.append('finance_books', {
+ 'depreciation_method': doc.depreciation_method,
+ 'total_number_of_depreciations': doc.total_number_of_depreciations,
+ 'frequency_of_depreciation': doc.frequency_of_depreciation,
+ 'depreciation_start_date': doc.next_depreciation_date,
+ 'expected_value_after_useful_life': doc.expected_value_after_useful_life,
+ 'value_after_depreciation': doc.value_after_depreciation
+ })
- fb.db_update()
+ fb.db_update()
frappe.db.sql(""" update `tabDepreciation Schedule` ds, `tabAsset` ast
set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """)