From 29458836e4cc6a229952db5a8fb00d281ba63922 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 13 Jan 2017 12:51:19 +0530 Subject: [PATCH] [Fix] After amend the status become cancelled even if docstatus is zero --- erpnext/controllers/status_updater.py | 2 ++ erpnext/patches.txt | 1 + erpnext/patches/v7_2/update_doctype_status.py | 11 +++++++++++ 3 files changed, 14 insertions(+) create mode 100644 erpnext/patches/v7_2/update_doctype_status.py diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py index 096bb2df71..4fbee58c84 100644 --- a/erpnext/controllers/status_updater.py +++ b/erpnext/controllers/status_updater.py @@ -103,6 +103,8 @@ class StatusUpdater(Document): def set_status(self, update=False, status=None, update_modified=True): if self.is_new(): + if self.get('amended_from'): + self.status = 'Draft' return if self.doctype in status_map: diff --git a/erpnext/patches.txt b/erpnext/patches.txt index ef1e2c12a9..f74b171066 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -360,3 +360,4 @@ erpnext.patches.v7_1.set_sales_person_status erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statment'}) erpnext.patches.v7_2.update_website_for_variant +erpnext.patches.v7_2.update_doctype_status \ No newline at end of file diff --git a/erpnext/patches/v7_2/update_doctype_status.py b/erpnext/patches/v7_2/update_doctype_status.py new file mode 100644 index 0000000000..c66f3f2e73 --- /dev/null +++ b/erpnext/patches/v7_2/update_doctype_status.py @@ -0,0 +1,11 @@ +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + doctypes = ["Opportunity", "Quotation", "Sales Order", "Sales Invoice", "Purchase Invoice", "Purchase Order", "Delivery Note", "Purchase Receipt"] + for doctype in doctypes: + frappe.db.sql(""" update `tab{doctype}` set status = 'Draft' + where status = 'Cancelled' and docstatus = 0 """.format(doctype = doctype)) \ No newline at end of file