From 112fc888f1a2ec52d8c736669111fd62e6808109 Mon Sep 17 00:00:00 2001 From: Marica Date: Wed, 18 Aug 2021 15:29:48 +0530 Subject: [PATCH] fix: Return Qty in PR/DN for legacy data (#27001) --- .../patches/v13_0/update_returned_qty_in_pr_dn.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/erpnext/patches/v13_0/update_returned_qty_in_pr_dn.py b/erpnext/patches/v13_0/update_returned_qty_in_pr_dn.py index 7f42cd92e3..409f4da859 100644 --- a/erpnext/patches/v13_0/update_returned_qty_in_pr_dn.py +++ b/erpnext/patches/v13_0/update_returned_qty_in_pr_dn.py @@ -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`