diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f42799fb846..1f082587540 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -484,3 +484,4 @@ erpnext.patches.v10_0.copy_projects_renamed_fields erpnext.patches.v10_0.enabled_regional_print_format_based_on_country erpnext.patches.v10_0.update_asset_calculate_depreciation erpnext.patches.v10_0.add_guardian_role_for_parent_portal +erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank \ No newline at end of file diff --git a/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py b/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py new file mode 100644 index 00000000000..6825f19d74d --- /dev/null +++ b/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py @@ -0,0 +1,35 @@ +# Copyright (c) 2017, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + item_numeric_attributes = frappe.db.sql(""" + select name, numeric_values, from_range, to_range, increment + from `tabItem Attribute` + where numeric_values = 1 + """, as_dict=1) + + for d in item_numeric_attributes: + frappe.db.sql(""" + update `tabItem Variant Attribute` + set + from_range = CASE + WHEN from_range = 0 THEN %(from_range)s + ELSE from_range + END, + to_range = CASE + WHEN to_range = 0 THEN %(to_range)s + ELSE to_range + END, + increment = CASE + WHEN increment = 0 THEN %(increment)s + ELSE increment + END, + numeric_values = %(numeric_values)s + where + attribute = %(name)s + and exists(select name from tabItem + where name=`tabItem Variant Attribute`.parent and has_variants=1) + """, d) \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 428e3663c21..7d18dd6f606 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -1532,7 +1532,7 @@ "report_hide": 0, "reqd": 0, "search_index": 0, - "set_only_once": 1, + "set_only_once": 0, "unique": 0 }, { @@ -3453,7 +3453,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2017-12-13 07:20:25.932499", + "modified": "2017-12-27 15:47:17.039337", "modified_by": "Administrator", "module": "Stock", "name": "Item",