fiix: cannot cancel asset and asset movement
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 2ecabe6..0b5a2ce 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -35,9 +35,6 @@
if not self.booked_fixed_asset and self.validate_make_gl_entry():
self.make_gl_entries()
- def before_cancel(self):
- self.cancel_auto_gen_movement()
-
def on_cancel(self):
self.validate_cancellation()
self.delete_depreciation_entries()
@@ -134,19 +131,6 @@
Please do not book expense of multiple assets against one single Asset.")
.format(frappe.bold("equal"), "<br>"), title=_("Invalid Gross Purchase Amount"))
- def cancel_auto_gen_movement(self):
- movements = frappe.db.sql(
- """SELECT asm.name, asm.docstatus
- FROM `tabAsset Movement` asm, `tabAsset Movement Item` asm_item
- WHERE asm_item.parent=asm.name and asm_item.asset=%s and asm.docstatus=1""", self.name, as_dict=1)
- if len(movements) > 1:
- frappe.throw(_('Asset has multiple Asset Movement Entries which has to be \
- cancelled manually to cancel this asset.'))
- if movements:
- movement = frappe.get_doc('Asset Movement', movements[0].get('name'))
- movement.flags.ignore_validate = True
- movement.cancel()
-
def make_asset_movement(self):
reference_doctype = 'Purchase Receipt' if self.purchase_receipt else 'Purchase Invoice'
reference_docname = self.purchase_receipt or self.purchase_invoice
diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.py b/erpnext/assets/doctype/asset_movement/asset_movement.py
index 3da355e..b2de250 100644
--- a/erpnext/assets/doctype/asset_movement/asset_movement.py
+++ b/erpnext/assets/doctype/asset_movement/asset_movement.py
@@ -87,33 +87,9 @@
def on_submit(self):
self.set_latest_location_in_asset()
-
- def before_cancel(self):
- self.validate_last_movement()
def on_cancel(self):
self.set_latest_location_in_asset()
-
- def validate_last_movement(self):
- for d in self.assets:
- auto_gen_movement_entry = frappe.db.sql(
- """
- SELECT asm.name
- FROM `tabAsset Movement Item` asm_item, `tabAsset Movement` asm
- WHERE
- asm.docstatus=1 and
- asm_item.parent=asm.name and
- asm_item.asset=%s and
- asm.company=%s and
- asm_item.source_location is NULL and
- asm.purpose=%s
- ORDER BY
- asm.transaction_date asc
- """, (d.asset, self.company, 'Receipt'), as_dict=1)
-
- if auto_gen_movement_entry and auto_gen_movement_entry[0].get('name') == self.name:
- frappe.throw(_('{0} will be cancelled automatically on asset cancellation as it was \
- auto generated for Asset {1}').format(self.name, d.asset))
def set_latest_location_in_asset(self):
current_location, current_employee = '', ''