Set numeric ranges in Item tamplate if blank (#12199)

This commit is contained in:
Nabin Hait 2017-12-28 12:35:11 +05:30 committed by GitHub
parent 28ce1c0c3a
commit ca674bec42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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",