From 0c677aa151c541f6939a51b4a7ecea3533b989be Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 4 Mar 2015 12:08:28 +0530 Subject: [PATCH] fix #2847 --- erpnext/patches/v5_0/update_time_log_title.py | 2 +- .../notification_control.js | 26 ++++++++++++------- .../notification_control.json | 6 ++--- .../notification_control.py | 14 ++-------- erpnext/stock/doctype/item/item.json | 6 ++--- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/erpnext/patches/v5_0/update_time_log_title.py b/erpnext/patches/v5_0/update_time_log_title.py index c1e911257c..8263be0007 100644 --- a/erpnext/patches/v5_0/update_time_log_title.py +++ b/erpnext/patches/v5_0/update_time_log_title.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals diff --git a/erpnext/setup/doctype/notification_control/notification_control.js b/erpnext/setup/doctype/notification_control/notification_control.js index da1c7c4591..409f99b563 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.js +++ b/erpnext/setup/doctype/notification_control/notification_control.js @@ -1,13 +1,19 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.select_transaction = function(doc, cdt, cdn) { - if(doc.select_transaction) { - var callback = function(r,rt) { - var doc = locals[cdt][cdn]; - doc.custom_message = r.message; - refresh_field('custom_message'); - } - return $c_obj(doc,'get_message',doc.select_transaction, callback) - } -} +frappe.ui.form.on("Notification Control", { + select_transaction: function(frm) { + frm.set_value("custom_message", frm.events.get_fieldname(frm)); + }, + set_message: function(frm) { + frm.set_value(frm.events.get_fieldname(frm), frm.doc.custom_message); + frm.save(); + }, + get_fieldname: function(frm) { + return frm.doc.select_transaction.replace(" ", "_").toLowerCase() + "_message"; + }, + after_save: function(frm) { + // update notification settings in current session + frappe.boot.notification_settings = frm.doc; + } +}); diff --git a/erpnext/setup/doctype/notification_control/notification_control.json b/erpnext/setup/doctype/notification_control/notification_control.json index fe1c57d6d7..f81801d95b 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.json +++ b/erpnext/setup/doctype/notification_control/notification_control.json @@ -102,10 +102,10 @@ "permlevel": 0 }, { - "fieldname": "update", + "fieldname": "set_message", "fieldtype": "Button", "label": "Update", - "options": "set_message", + "options": "", "permlevel": 0 }, { @@ -176,7 +176,7 @@ "icon": "icon-envelope", "idx": 1, "issingle": 1, - "modified": "2015-02-05 05:11:41.580894", + "modified": "2015-03-04 01:13:46.715113", "modified_by": "Administrator", "module": "Setup", "name": "Notification Control", diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py index 7eb00ce2e2..c50bacac4c 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.py +++ b/erpnext/setup/doctype/notification_control/notification_control.py @@ -4,18 +4,8 @@ from __future__ import unicode_literals import frappe -from frappe import _ - from frappe.model.document import Document class NotificationControl(Document): - def get_message(self, arg): - fn = arg.lower().replace(' ', '_') + '_message' - v = frappe.db.sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control')) - return v and v[0][0] or '' - - def set_message(self, arg = ''): - fn = self.select_transaction.lower().replace(' ', '_') + '_message' - frappe.db.set(self, fn, self.custom_message) - frappe.msgprint(_("Message updated")) - + def validate(self): + frappe.clear_cache() diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index f64dec6d77..b34983df67 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -728,10 +728,10 @@ }, { "default": "No", - "description": "Select \"Yes\" if you supply raw materials to your supplier to manufacture this item.", + "description": "", "fieldname": "is_sub_contracted_item", "fieldtype": "Select", - "label": "Is Sub Contracted Item", + "label": "Supply Raw Materials for Purchase", "oldfieldname": "is_sub_contracted_item", "oldfieldtype": "Select", "options": "Yes\nNo", @@ -877,7 +877,7 @@ "icon": "icon-tag", "idx": 1, "max_attachments": 1, - "modified": "2015-03-02 07:48:53.411086", + "modified": "2015-03-03 06:18:35.717586", "modified_by": "Administrator", "module": "Stock", "name": "Item",