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>
This commit is contained in:
Ankush Menat 2021-06-04 13:09:14 +05:30 committed by GitHub
parent 3f45901f25
commit 215516f819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -497,7 +497,7 @@ class PurchaseReceipt(BuyingController):
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 @@ def get_item_account_wise_additional_cost(purchase_document):
account.base_amount * item.get(based_on_field) / total_item_cost
return item_account_wise_cost