fix: Return Qty in PR/DN for legacy data (#27001)
This commit is contained in:
parent
cab49254fc
commit
112fc888f1
@ -1,8 +1,7 @@
|
||||
# Copyright (c) 2019, Frappe and Contributors
|
||||
# Copyright (c) 2021, Frappe and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from erpnext.controllers.status_updater import OverAllowanceError
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc('stock', 'doctype', 'purchase_receipt')
|
||||
@ -14,9 +13,15 @@ def execute():
|
||||
for return_doc in frappe.get_all(doctype, filters={'is_return' : 1, 'docstatus' : 1}):
|
||||
# Update original receipt/delivery document from return
|
||||
return_doc = frappe.get_cached_doc(doctype, return_doc.name)
|
||||
return_doc.update_prevdoc_status()
|
||||
try:
|
||||
return_doc.update_prevdoc_status()
|
||||
except OverAllowanceError:
|
||||
frappe.db.rollback()
|
||||
continue
|
||||
|
||||
return_against = frappe.get_doc(doctype, return_doc.return_against)
|
||||
return_against.update_billing_status()
|
||||
frappe.db.commit()
|
||||
|
||||
# Set received qty in stock uom in PR, as returned qty is checked against it
|
||||
frappe.db.sql(""" update `tabPurchase Receipt Item`
|
||||
|
Loading…
x
Reference in New Issue
Block a user