From e27690ceda56c03217f46cc95ab556507074390c Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 8 May 2015 12:42:46 +0530 Subject: [PATCH] Fixed issue while updating Requested Qty on stoping material request and patch to recalculate --- erpnext/patches.txt | 1 + erpnext/patches/v4_2/repost_requested_qty.py | 21 +++++++++++++++++++ .../material_request/material_request.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v4_2/repost_requested_qty.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index bccbe79686..a9e979b48e 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -99,3 +99,4 @@ erpnext.patches.v4_2.repost_sle_for_si_with_no_warehouse erpnext.patches.v4_2.fix_recurring_orders erpnext.patches.v4_2.delete_gl_entries_for_cancelled_invoices erpnext.patches.v4_2.update_advance_paid +erpnext.patches.v4_2.repost_requested_qty diff --git a/erpnext/patches/v4_2/repost_requested_qty.py b/erpnext/patches/v4_2/repost_requested_qty.py new file mode 100644 index 0000000000..8c1d6f7fbb --- /dev/null +++ b/erpnext/patches/v4_2/repost_requested_qty.py @@ -0,0 +1,21 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + from erpnext.utilities.repost_stock import update_bin_qty, get_indented_qty + + count=0 + for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse + from `tabMaterial Request Item` where docstatus = 1"""): + try: + count += 1 + update_bin_qty(item_code, warehouse, { + "indented_qty": get_indented_qty(item_code, warehouse), + }) + if count % 200 == 0: + frappe.db.commit() + except: + frappe.db.rollback() diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index ff11f26784..c46eaff642 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -94,8 +94,8 @@ class MaterialRequest(BuyingController): def update_status(self, status): self.check_modified_date() - self.update_requested_qty() frappe.db.set(self, 'status', cstr(status)) + self.update_requested_qty() frappe.msgprint(_("Status updated to {0}").format(_(status))) def on_cancel(self):