From e74e4b18c742a5028dd02d170e3f63d5c42294c1 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Thu, 13 Jul 2017 14:17:07 +0530 Subject: [PATCH] [patch][fix] update gst_state only if company country is india --- erpnext/patches.txt | 4 ++-- erpnext/patches/v8_1/update_gst_state.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8991c36342..fd985d0f4d 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -415,5 +415,5 @@ erpnext.patches.v8_1.gst_fixes #2017-07-06 erpnext.patches.v8_0.update_production_orders erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit -erpnext.patches.v8_1.update_gst_state -erpnext.patches.v8_1.add_hsn_sac_codes \ No newline at end of file +erpnext.patches.v8_1.add_hsn_sac_codes +erpnext.patches.v8_1.update_gst_state \ No newline at end of file diff --git a/erpnext/patches/v8_1/update_gst_state.py b/erpnext/patches/v8_1/update_gst_state.py index 2bbb6b8a8e..88fe6eb32d 100644 --- a/erpnext/patches/v8_1/update_gst_state.py +++ b/erpnext/patches/v8_1/update_gst_state.py @@ -2,5 +2,12 @@ import frappe from erpnext.regional.india import states def execute(): + company = frappe.get_all('Company', filters = {'country': 'India'}) + if not company: + return + + if not frappe.db.get_value("Custom Field", filters={'fieldname':'gst_state'}): + return + frappe.db.sql("update `tabCustom Field` set options=%s where fieldname='gst_state'", '\n'.join(states)) frappe.db.sql("update `tabAddress` set gst_state='Chhattisgarh' where gst_state='Chattisgarh'")