From f51661b225d0fe007901f098d2d80cb5d0b88965 Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 23 Jan 2019 16:42:28 +0530 Subject: [PATCH] fix: allow operators, make weighting_function mandatory --- .../supplier_scorecard.json | 2 +- erpnext/patches.txt | 3 ++- .../allow_operators_in_supplier_scorecard.py | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json index 95dc7518f63..6a077e9c354 100644 --- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json +++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.json @@ -252,7 +252,7 @@ "read_only": 0, "remember_last_selected_value": 0, "report_hide": 0, - "reqd": 0, + "reqd": 1, "search_index": 0, "set_only_once": 0, "unique": 0 diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 9d5b3311236..d34a3fb87d0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -507,4 +507,5 @@ erpnext.patches.v10_0.set_discount_amount erpnext.patches.v10_0.recalculate_gross_margin_for_project erpnext.patches.v10_0.delete_hub_documents erpnext.patches.v10_0.update_user_image_in_employee -erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items \ No newline at end of file +erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items +erpnext.patches.v10_0.allow_operators_in_supplier_scorecard \ No newline at end of file diff --git a/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py b/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py new file mode 100644 index 00000000000..27478f3ad5d --- /dev/null +++ b/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py @@ -0,0 +1,19 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + for criteria in frappe.get_all('Supplier Scorecard Criteria', fields=['name', 'formula'], limit_page_length=None): + frappe.db.set_value('Supplier Scorecard Criteria', criteria.name, + 'formula', criteria.formula.replace('<','<').replace('>','>')) + + for criteria in frappe.get_all('Supplier Scorecard Scoring Criteria', fields=['name', 'formula'], limit_page_length=None): + if criteria.formula: # not mandatory + frappe.db.set_value('Supplier Scorecard Scoring Criteria', criteria.name, + 'formula', criteria.formula.replace('<','<').replace('>','>')) + + for sc in frappe.get_all('Supplier Scorecard', fields=['name', 'weighting_function'], limit_page_length=None): + frappe.db.set_value('Supplier Scorecard', sc.name, 'weighting_function', + sc.weighting_function.replace('<','<').replace('>','>')) \ No newline at end of file