fix: auto cancel if movement exists (#20268)

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
Saqib
2020-01-14 12:42:43 +05:30
committed by Nabin Hait
parent 00f6f114e7
commit 2d37bbedaa

View File

@@ -132,6 +132,7 @@ class Asset(AccountsController):
if len(movements) > 1: if len(movements) > 1:
frappe.throw(_('Asset has multiple Asset Movement Entries which has to be \ frappe.throw(_('Asset has multiple Asset Movement Entries which has to be \
cancelled manually to cancel this asset.')) cancelled manually to cancel this asset.'))
if movements:
movement = frappe.get_doc('Asset Movement', movements[0].get('name')) movement = frappe.get_doc('Asset Movement', movements[0].get('name'))
movement.flags.ignore_validate = True movement.flags.ignore_validate = True
movement.cancel() movement.cancel()