fix: AttributeError: 'PurchaseReceiptItem' object has no attribute 'purchase_invoice' (#25902) (#25957)
* fix: AttributeError: 'PurchaseReceiptItem' object has no attribute 'purchase_invoice'
This error occurs when upgrading from erpnext 13.0.1 to 13.4.0 after typing
bench update --patch --reset
* fix(minor): use .get instead of getattr
Co-authored-by: D Tim Cummings <tim@triptera.com.au>
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index f1292d8..83ba324 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -497,7 +497,7 @@
def update_billing_status(self, update_modified=True):
updated_pr = [self.name]
for d in self.get("items"):
- if d.purchase_invoice and d.purchase_invoice_item:
+ if d.get("purchase_invoice") and d.get("purchase_invoice_item"):
d.db_set('billed_amt', d.amount, update_modified=update_modified)
elif d.purchase_order_item:
updated_pr += update_billed_amount_based_on_po(d.purchase_order_item, update_modified)
@@ -748,4 +748,3 @@
account.base_amount * item.get(based_on_field) / total_item_cost
return item_account_wise_cost
-