Merge pull request #33946 from AnandBaburajan/cancel_pi_cancelled_asset
fix: allow cancelling purchase invoice if linked asset is already cancelled
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 54f0d94..4f7d9ad 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -712,6 +712,8 @@
asset.purchase_date = self.posting_date
asset.supplier = self.supplier
elif self.docstatus == 2:
+ if asset.docstatus == 2:
+ continue
if asset.docstatus == 0:
asset.set(field, None)
asset.supplier = None