From d7fe2bfe1b2158ecdb91ec4df200af23e5600c89 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 29 Nov 2012 11:49:56 +0530 Subject: [PATCH 1/6] webnotes.model.doctype (new version) --- .../voucher_import_tool.py | 6 +- patches/april_2012/change_cacheitem_schema.py | 6 - patches/june_2012/cache_item_table.py | 12 - patches/mar_2012/doctype_get_refactor.py | 4 +- patches/may_2012/remove_communication_log.py | 5 +- patches/patch_list.py | 10 - public/js/communication.js | 144 -------- selling/doctype/lead/lead.js | 3 +- setup/doctype/naming_series/naming_series.py | 3 +- .../permission_control/permission_control.py | 10 +- support/doctype/communication/__init__.py | 1 - .../doctype/communication/communication.js | 142 ------- .../doctype/communication/communication.py | 110 ------ .../doctype/communication/communication.txt | 347 ------------------ .../communication/communication_list.js | 43 --- .../doctype/support_ticket/support_ticket.js | 4 +- utilities/doctype/contact/contact.js | 5 +- utilities/doctype/contact/contact_list.js | 2 +- 18 files changed, 15 insertions(+), 842 deletions(-) delete mode 100644 patches/april_2012/change_cacheitem_schema.py delete mode 100644 patches/june_2012/cache_item_table.py delete mode 100644 public/js/communication.js delete mode 100644 support/doctype/communication/__init__.py delete mode 100644 support/doctype/communication/communication.js delete mode 100644 support/doctype/communication/communication.py delete mode 100644 support/doctype/communication/communication.txt delete mode 100644 support/doctype/communication/communication_list.js diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 41d0a9f474..3a50f9d70c 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -6,9 +6,9 @@ from webnotes.utils import formatdate, flt def get_template(): """download template""" template_type = webnotes.form_dict.get('type') - from webnotes.model.doctype import get_field_property - naming_options = get_field_property("Journal Voucher", "naming_series", "options") - voucher_type = get_field_property("Journal Voucher", "voucher_type", "options") + from webnotes.model.doctype import get_property + naming_options = get_property("Journal Voucher", "naming_series", "options") + voucher_type = get_property("Journal Voucher", "voucher_type", "options") if template_type=="Two Accounts": extra_note = "" columns = '''"Naming Series","Voucher Type","Posting Date","Amount","Debit Account","Credit Account","Cost Center","Against Sales Invoice","Against Purchase Invoice","Against Journal Voucher","Remarks","Due Date","Ref Number","Ref Date"''' diff --git a/patches/april_2012/change_cacheitem_schema.py b/patches/april_2012/change_cacheitem_schema.py deleted file mode 100644 index 4d46f2cef0..0000000000 --- a/patches/april_2012/change_cacheitem_schema.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import unicode_literals -def execute(): - import webnotes - webnotes.conn.commit() - webnotes.conn.sql("alter table __CacheItem modify `value` longtext") - webnotes.conn.begin() diff --git a/patches/june_2012/cache_item_table.py b/patches/june_2012/cache_item_table.py deleted file mode 100644 index 771b409595..0000000000 --- a/patches/june_2012/cache_item_table.py +++ /dev/null @@ -1,12 +0,0 @@ -from __future__ import unicode_literals -def execute(): - """drop and create __CacheItem table again""" - import webnotes - webnotes.conn.commit() - webnotes.conn.sql("drop table __CacheItem") - webnotes.conn.sql("""create table __CacheItem( - `key` VARCHAR(180) NOT NULL PRIMARY KEY, - `value` LONGTEXT, - `expires_on` DATETIME - ) ENGINE=MyISAM DEFAULT CHARSET=utf8""") - webnotes.conn.begin() \ No newline at end of file diff --git a/patches/mar_2012/doctype_get_refactor.py b/patches/mar_2012/doctype_get_refactor.py index 26cee77910..66339db122 100644 --- a/patches/mar_2012/doctype_get_refactor.py +++ b/patches/mar_2012/doctype_get_refactor.py @@ -116,8 +116,8 @@ def create_file_list(): obj.make_file_list() from webnotes.model.db_schema import updatedb updatedb(obj.doc.name) - from webnotes.utils.cache import CacheItem - CacheItem(obj.doc.name).clear() + + webnotes.clear_cache(doctype=obj.doc.name) def change_to_decimal(): print "in change to decimal" diff --git a/patches/may_2012/remove_communication_log.py b/patches/may_2012/remove_communication_log.py index 28bfca1ff6..e44e673701 100644 --- a/patches/may_2012/remove_communication_log.py +++ b/patches/may_2012/remove_communication_log.py @@ -50,9 +50,8 @@ def move_customizations(): webnotes.conn.sql("""\ delete from `tabProperty Setter` where doc_type='Communication Log'""") - - from webnotes.utils.cache import CacheItem - CacheItem('Communication').clear() + + webnotes.clear_cache(doctype="Communication") def remove_communication_log(): import webnotes diff --git a/patches/patch_list.py b/patches/patch_list.py index 0bf4d3c05e..31289484b2 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -278,11 +278,6 @@ patch_list = [ 'patch_file': 'after_sync_cleanup', 'description': 'cleanup after sync' }, - { - 'patch_module': 'patches.april_2012', - 'patch_file': 'change_cacheitem_schema', - 'description': 'Modified datatype of `value` column from text to longtext' - }, { 'patch_module': 'patches.april_2012', 'patch_file': 'remove_default_from_rv_detail', @@ -458,11 +453,6 @@ patch_list = [ 'patch_file': 'delete_about_contact', 'description': "delete depracated doctypes of website module" }, - { - 'patch_module': 'patches.june_2012', - 'patch_file': 'cache_item_table', - 'description': "create cache item table again" - }, { 'patch_module': 'patches.july_2012', 'patch_file': 'reload_pr_po_mapper', diff --git a/public/js/communication.js b/public/js/communication.js deleted file mode 100644 index 70a08affec..0000000000 --- a/public/js/communication.js +++ /dev/null @@ -1,144 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// opts - parent, list, doc, email -erpnext.CommunicationView = Class.extend({ - init: function(opts) { - this.comm_list = []; - $.extend(this, opts); - - if(this.doc.__islocal) { - return; - } - - this.list.sort(function(a, b) { return - (new Date(a.modified) > new Date(b.modified)) - ? -1 : 1; }) - - this.make(); - }, - make: function() { - var me = this; - this.make_body(); - - if(this.list && this.list.length) { - $.each(this.list, function(i, d) { - me.prepare(d); - me.make_line(d); - }); - // show first - this.comm_list[0].find('.comm-content').toggle(true); - } else { - this.body.remove() - $("
No Communication with this " - + this.doc.doctype +" yet.
").appendTo(this.wrapper); - } - - }, - make_body: function() { - $(this.parent) - .html("") - .css({"margin":"10px 0px"}); - - this.wrapper = $("

Communication History

\ -
\ -
\ -
") - .appendTo(this.parent); - - this.body = $("") - .appendTo(this.wrapper); - }, - add_reply: function() { - var me = this; - var d = new wn.ui.Dialog({ - width: 640, - title: "Add Reply: " + (this.doc.subject || ""), - fields: [ - {label:"Subject", fieldtype:"Data", reqd: 1}, - {label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"}, - {label:"Send Email", fieldtype:"Check"}, - {label:"Add Reply", fieldtype:"Button"}, - ] - }); - - $(d.fields_dict.send_email.input).attr("checked", "checked") - $(d.fields_dict.add_reply.input).click(function() { - var args = d.get_values(); - if(!args) return; - $(this).set_working(); - wn.call({ - method:"support.doctype.communication.communication.make", - args: $.extend(args, { - doctype: me.doc.doctype, - name: me.doc.name, - lead: me.doc.lead, - contact: me.doc.contact, - recipients: me.email - }), - callback: function(r) { - d.hide(); - cur_frm.reload_doc(); - } - }); - }); - - if(me.list.length > 0) { - d.fields_dict.content.input.set_input("

" - + (wn.boot.profile.email_signature || "") - +"

" - +"-----In response to-----

" - + me.list[0].content) - } else { - - } - $(d.fields_dict.subject.input).val(this.doc.subject || "").change(); - - d.show(); - }, - - prepare: function(doc) { - //doc.when = comment_when(this.doc.modified); - doc.when = doc.modified; - if(doc.content.indexOf("
")== -1 && doc.content.indexOf("

")== -1) { - doc.content = doc.content.replace(/\n/g, "
"); - } - if(!doc.sender) doc.sender = "[unknown sender]"; - doc.sender = doc.sender.replace(//, ">"); - doc.content = doc.content.split("-----In response to-----")[0]; - doc.content = doc.content.split("-----Original Message-----")[0]; - }, - make_line: function(doc) { - var me = this; - var comm = $(repl('

', doc)) - .appendTo(this.body) - .css({"cursor":"pointer"}) - .click(function() { - $(this).find(".comm-content").toggle(); - }); - - this.comm_list.push(comm); - comm.find(".comm-content").html(doc.content); - } -}) diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 39522f86cc..081a57a0fd 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -16,7 +16,6 @@ // Module CRM -wn.require("public/app/js/communication.js"); wn.require('app/utilities/doctype/sms_control/sms_control.js'); cur_frm.cscript.onload = function(doc, cdt, cdn) { @@ -68,7 +67,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.refresh_custom_buttons(doc); erpnext.hide_naming_series(); - cur_frm.communication_view = new erpnext.CommunicationView({ + cur_frm.communication_view = new wn.views.CommunicationList({ list: wn.model.get("Communication", {"lead": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, diff --git a/setup/doctype/naming_series/naming_series.py b/setup/doctype/naming_series/naming_series.py index 689b40990b..c40e932f31 100644 --- a/setup/doctype/naming_series/naming_series.py +++ b/setup/doctype/naming_series/naming_series.py @@ -90,8 +90,7 @@ class DocType: self.doc.set_options = "\n".join(options) - from webnotes.utils.cache import CacheItem - CacheItem(doctype).clear() + webnotes.clear_cache(doctype=doctype) def check_duplicate(self): from core.doctype.doctype.doctype import DocType diff --git a/setup/doctype/permission_control/permission_control.py b/setup/doctype/permission_control/permission_control.py index 32efe03785..d7a80a828b 100644 --- a/setup/doctype/permission_control/permission_control.py +++ b/setup/doctype/permission_control/permission_control.py @@ -20,7 +20,7 @@ import webnotes from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, getchildren, make_autoname +from webnotes.model.doc import Document, addchild, getchildren from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes import session, form, msgprint, errprint @@ -30,9 +30,6 @@ sql = webnotes.conn.sql get_value = webnotes.conn.get_value in_transaction = webnotes.conn.in_transaction convert_to_lists = webnotes.conn.convert_to_lists - -# ----------------------------------------------------------------------------------------- - class DocType: def __init__(self, doc, doclist): @@ -60,7 +57,7 @@ class DocType: # ------------------------------------------------------------------- def get_permissions(self,doctype): import webnotes.model.doctype - doclist = webnotes.model.doctype.get(doctype, form=0) + doclist = webnotes.model.doctype.get(doctype) ptype = [{ 'role': perm.role, @@ -195,8 +192,7 @@ class DocType: sql("update tabDocType set modified = %s where name = %s",(now(), parent)) - from webnotes.utils.cache import CacheItem - CacheItem(parent).clear() + webnotes.clear_cache(doctype=parent) msgprint("Permissions Updated") diff --git a/support/doctype/communication/__init__.py b/support/doctype/communication/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/support/doctype/communication/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/support/doctype/communication/communication.js b/support/doctype/communication/communication.js deleted file mode 100644 index 04e6c804de..0000000000 --- a/support/doctype/communication/communication.js +++ /dev/null @@ -1,142 +0,0 @@ -cur_frm.cscript.onload = function(doc) { - cur_frm.fields_dict.user.get_query = function() { - return "select name, concat_ws(' ', first_name, middle_name, last_name) \ - from `tabProfile` where ifnull(enabled, 0)=1 and docstatus < 2 and \ - (%(key)s like \"%s\" or \ - concat_ws(' ', first_name, middle_name, last_name) like \"%%%s\") \ - limit 50"; - }; - - cur_frm.fields_dict.lead.get_query = function() { - return "select name, lead_name from `tabLead` \ - where docstatus < 2 and \ - (%(key)s like \"%s\" or lead_name like \"%%%s\" or \ - company_name like \"%%%s\") \ - order by lead_name asc limit 50"; - }; - - cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; - cur_frm.fields_dict.supplier.get_query = erpnext.utils.supplier_query; -} - -cur_frm.cscript.refresh = function(doc, dt, dn) { - if(!doc.__islocal) { - var field_list = ['lead', 'customer', 'supplier', 'contact', 'opportunity', - 'quotation', 'support_ticket']; - var hide_list = []; - $.each(field_list, function(i, v) { - if(!doc[v]) hide_list.push(v); - }); - - if(hide_list.length < field_list.length) hide_field(hide_list); - } -} - - -cur_frm.cscript.make_communication_body = function() { - var communication_wrapper = cur_frm.fields_dict.communication_html.wrapper; - communication_wrapper.innerHTML = ''; - cur_frm.communication_html = $a(communication_wrapper, 'div'); - $(cur_frm.communication_html).css({ - 'min-height': '275px', - }); -} - -cur_frm.cscript.render_communication_list = function(doc, dt, dn) { - var ListView = wn.views.ListView.extend({ - init: function(doclistview) { - this._super(doclistview); - this.fields = this.fields.concat([ - "`tabCommunication`.communication_date", - "`tabCommunication`.category", - "`tabCommunication`.subject", - "`tabCommunication`.content" - ]); - this.order_by = "`tabCommunication`.communication_date desc"; - }, - - prepare_data: function(data) { - this._super(data); - this.prepare_when(data, data.creation); - - // escape double quote - data.content = cstr(data.subject).replace(/"/gi, '\"') - + " | " + cstr(data.content).replace(/"/gi, '\"'); - - if(data.content && data.content.length > 50) { - data.content = '' + - data.content.substr(0,50) + '...'; - } - - }, - - columns: [ - {width: '3%', content: 'docstatus'}, - {width: '15%', content: 'name'}, - {width: '15%', content: 'category'}, - {width: '55%', content: 'content'}, - {width: '12%', content:'when', - css: {'text-align': 'right', 'color':'#777'}} - ], - - }); - - cur_frm.cscript.render_list(doc, 'Communication', cur_frm.communication_html, - ListView, function(doctype) { - var new_doc = LocalDB.create(doctype); - new_doc = locals[doctype][new_doc]; - new_doc[doc.doctype.toLowerCase().replace(" ", "_")] = doc.name; - loaddoc(new_doc.doctype, new_doc.name); - }); -} - - -// Render List -cur_frm.cscript.render_list = function(doc, doctype, wrapper, ListView, make_new_doc) { - wn.model.with_doctype(doctype, function(r) { - if((r && r['403']) || wn.boot.profile.all_read.indexOf(doctype)===-1) { - return; - } - var RecordListView = wn.views.RecordListView.extend({ - default_docstatus: ['0', '1', '2'], - default_filters: [ - [doctype, doc.doctype.toLowerCase().replace(" ", "_"), '=', doc.name], - ], - }); - - if (make_new_doc) { - RecordListView = RecordListView.extend({ - make_new_doc: make_new_doc, - }); - } - - var record_list_view = new RecordListView(doctype, wrapper, ListView); - if (!cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"]) { - cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"] = record_list_view; - } - }); -} - - -cur_frm.cscript.contact = function(doc, dt, dn) { - if (doc.contact) { - wn.call({ - method: 'support.doctype.communication.communication.get_customer_supplier', - args: { - contact: doc.contact - }, - callback: function(r, rt) { - if (!r.exc && r.message) { - doc = locals[doc.doctype][doc.name]; - doc[r.message['fieldname']] = r.message['value']; - refresh_field(r.message['fieldname']); - } - }, - }); - } -} - -cur_frm.cscript.hide_dialog = function() { - if(cur_frm.communication_list) - cur_frm.communication_list.run(); -} \ No newline at end of file diff --git a/support/doctype/communication/communication.py b/support/doctype/communication/communication.py deleted file mode 100644 index f365fe38b4..0000000000 --- a/support/doctype/communication/communication.py +++ /dev/null @@ -1,110 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes -from webnotes.model.doc import make_autoname - -@webnotes.whitelist() -def get_customer_supplier(args=None): - """ - Get Customer/Supplier, given a contact, if a unique match exists - """ - import webnotes - if not args: args = webnotes.form_dict - if not args.get('contact'): - raise Exception, "Please specify a contact to fetch Customer/Supplier" - result = webnotes.conn.sql("""\ - select customer, supplier - from `tabContact` - where name = %s""", args.get('contact'), as_dict=1) - if result and len(result)==1 and (result[0]['customer'] or result[0]['supplier']): - return { - 'fieldname': result[0]['customer'] and 'customer' or 'supplier', - 'value': result[0]['customer'] or result[0]['supplier'] - } - return {} - -@webnotes.whitelist() -def make(doctype=None, name=None, content=None, subject=None, - sender=None, recipients=None, contact=None, lead=None, - communication_medium="Email", send_email=False): - # add to Communication - - sent_via = None - - d = webnotes.doc('Communication') - d.subject = subject - d.content = content - d.sender = sender or webnotes.conn.get_value("Profile", webnotes.session.user, "email") - d.recipients = recipients - d.lead = lead - d.contact = contact - if doctype: - sent_via = webnotes.get_obj(doctype, name) - d.fields[doctype.replace(" ", "_").lower()] = name - - set_lead_and_contact(d) - d.communication_medium = communication_medium - if send_email: - send_comm_email(d, sent_via) - d.save(1) - -def send_comm_email(d, sent_via=None): - from webnotes.utils.email_lib import sendmail - - if sent_via: - if hasattr(sent_via, "get_sender"): - d.sender = sent_via.get_sender(d) - if hasattr(sent_via, "get_subject"): - d.subject = sent_via.get_subject(d) - if hasattr(sent_via, "get_content"): - d.content = sent_via.get_content(d) - - sendmail(\ - recipients = d.recipients.split(","), \ - sender = d.sender, \ - subject = d.subject, \ - msg= d.content) - - if sent_via and hasattr(sent_via, 'on_communication_sent'): - sent_via.on_communication_sent(d) - -def set_lead_and_contact(d): - import email.utils - email_addr = email.utils.parseaddr(d.sender) - # set contact - if not d.contact: - d.contact = webnotes.conn.get_value("Contact", {"email_id": email_addr[1]}, "name") or None - - if not d.lead: - d.lead = webnotes.conn.get_value("Lead", {"email_id": email_addr[1]}, "name") or None - - if not d.lead and not d.contact: - d.lead = make_lead(d, email_addr[0]) - -def make_lead(d, real_name): - lead = webnotes.doc("Lead") - lead.lead_name = real_name or d.sender - lead.email_id = d.sender - lead.source = "Email" - lead.save(1) - return lead.name - -class DocType(): - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist diff --git a/support/doctype/communication/communication.txt b/support/doctype/communication/communication.txt deleted file mode 100644 index 1f01c50c38..0000000000 --- a/support/doctype/communication/communication.txt +++ /dev/null @@ -1,347 +0,0 @@ -[ - { - "owner": "Administrator", - "docstatus": 0, - "creation": "2012-11-14 12:25:16", - "modified_by": "Administrator", - "modified": "2012-11-27 18:51:01" - }, - { - "autoname": "naming_series:", - "allow_attach": 1, - "name": "__common__", - "doctype": "DocType", - "module": "Support", - "in_dialog": 0, - "document_type": "Master", - "description": "Keep a track of all communications" - }, - { - "name": "__common__", - "parent": "Communication", - "doctype": "DocField", - "parenttype": "DocType", - "parentfield": "fields" - }, - { - "name": "__common__", - "parent": "Communication", - "read": 1, - "doctype": "DocPerm", - "write": 1, - "parenttype": "DocType", - "parentfield": "permissions" - }, - { - "name": "Communication", - "doctype": "DocType" - }, - { - "doctype": "DocField", - "label": "Basic Info", - "fieldname": "basic_info", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "default": "COMM-", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Naming Series", - "options": "COMM-", - "fieldname": "naming_series", - "fieldtype": "Select", - "hidden": 1, - "permlevel": 0 - }, - { - "colour": "White:FFF", - "doctype": "DocField", - "label": "Subject", - "fieldname": "subject", - "fieldtype": "Data", - "reqd": 1, - "permlevel": 0 - }, - { - "colour": "White:FFF", - "doctype": "DocField", - "label": "Content", - "width": "400", - "fieldname": "content", - "fieldtype": "Text Editor", - "reqd": 0, - "permlevel": 0 - }, - { - "doctype": "DocField", - "options": "simple", - "fieldname": "section_break1", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Category", - "options": "\nSales\nComplaint\nHelp\nSuggestion\nMiscellaneous\nSent Mail", - "fieldname": "category", - "fieldtype": "Select", - "reqd": 0, - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Next Communcation On", - "fieldname": "next_communication_date", - "fieldtype": "Date", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Action", - "options": "\nCreated Opportunity\nSent Quotation\nCreated Support Ticket\nCreated Customer Issue\nNo Action\nSent Mail", - "fieldname": "action", - "fieldtype": "Select", - "reqd": 0, - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Additional Info", - "fieldname": "additional_info", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "colour": "White:FFF", - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Lead", - "options": "Lead", - "fieldname": "lead", - "fieldtype": "Link", - "hidden": 0, - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Contact", - "options": "Contact", - "fieldname": "contact", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Customer", - "options": "Customer", - "fieldname": "customer", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Supplier", - "options": "Supplier", - "fieldname": "supplier", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Opportunity", - "options": "Opportunity", - "fieldname": "opportunity", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Quotation", - "options": "Quotation", - "fieldname": "quotation", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Support Ticket", - "options": "Support Ticket", - "fieldname": "support_ticket", - "fieldtype": "Link", - "permlevel": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Recipients", - "fieldname": "recipients", - "fieldtype": "Data", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Sender", - "fieldname": "sender", - "fieldtype": "Data", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Communication Medium", - "options": "\nChat\nPhone\nEmail\nSMS\nVisit\nOther", - "fieldname": "communication_medium", - "fieldtype": "Select", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "Phone No.", - "fieldname": "phone_no", - "fieldtype": "Data", - "permlevel": 0 - }, - { - "doctype": "DocField", - "options": "simple", - "fieldname": "section_break2", - "fieldtype": "Section Break", - "permlevel": 0 - }, - { - "doctype": "DocField", - "label": "By", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "default": "__user", - "colour": "White:FFF", - "doctype": "DocField", - "label": "User", - "options": "Profile", - "fieldname": "user", - "fieldtype": "Link", - "permlevel": 1 - }, - { - "doctype": "DocField", - "label": "Sales Person", - "options": "Sales Person", - "fieldname": "sales_person", - "fieldtype": "Link", - "permlevel": 1 - }, - { - "doctype": "DocField", - "label": "On", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "permlevel": 0 - }, - { - "default": "Today", - "colour": "White:FFF", - "doctype": "DocField", - "label": "Date", - "fieldname": "communication_date", - "fieldtype": "Date", - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "doctype": "DocField", - "label": "File List", - "fieldname": "file_list", - "fieldtype": "Text", - "hidden": 1, - "permlevel": 0 - }, - { - "print_hide": 1, - "no_copy": 1, - "doctype": "DocField", - "label": "User Tags", - "fieldname": "_user_tags", - "fieldtype": "Data", - "hidden": 1, - "permlevel": 0 - }, - { - "amend": 0, - "create": 1, - "doctype": "DocPerm", - "submit": 0, - "role": "Support Team", - "cancel": 1, - "permlevel": 0 - }, - { - "amend": 0, - "create": 1, - "doctype": "DocPerm", - "submit": 0, - "role": "Sales Manager", - "cancel": 1, - "permlevel": 0 - }, - { - "amend": 0, - "create": 1, - "doctype": "DocPerm", - "submit": 0, - "role": "Sales User", - "cancel": 1, - "permlevel": 0 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "role": "Sales Manager", - "cancel": 0, - "permlevel": 1 - }, - { - "amend": 0, - "create": 0, - "doctype": "DocPerm", - "submit": 0, - "role": "Support Manager", - "cancel": 0, - "permlevel": 1 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "Support Manager", - "cancel": 1, - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "role": "System Manager", - "cancel": 1, - "permlevel": 0 - } -] \ No newline at end of file diff --git a/support/doctype/communication/communication_list.js b/support/doctype/communication/communication_list.js deleted file mode 100644 index 8c8d98c8b4..0000000000 --- a/support/doctype/communication/communication_list.js +++ /dev/null @@ -1,43 +0,0 @@ -wn.doclistviews['Communication'] = wn.views.ListView.extend({ - init: function(doclistview) { - this._super(doclistview); - this.fields = this.fields.concat([ - "`tabCommunication`.creation", - "`tabCommunication`.category", - "`tabCommunication`.subject", - "`tabCommunication`.content" - ]); - this.order_by = "`tabCommunication`.creation desc"; - this.stats = this.stats.concat(['category']); - }, - - prepare_data: function(data) { - this._super(data); - this.prepare_when(data, data.creation); - - // escape double quote - data.content = cstr(data.subject) - + " | " + cstr(data.content); - data.content = data.content.replace(/"/gi, '\"') - .replace(//gi, '>'); - - if(data.content && data.content.length > 50) { - data.content = '' + - data.content.substr(0,50) + '...'; - } - }, - - columns: [ - {width: '3%', content: 'check'}, - {width: '5%', content: 'avatar'}, - {width: '15%', content: 'name'}, - {width: '15%', content: 'category'}, - {width: '55%', content: 'content+tags'}, - {width: '12%', content:'when', - css: {'text-align': 'right', 'color':'#777'}} - ], - - make_new_doc: function(new_doctype) { - new_doc(new_doctype, 1); - } -}); \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 519d34391d..2d89c6e386 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -wn.require("public/app/js/communication.js"); - cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query; $.extend(cur_frm.cscript, { @@ -62,7 +60,7 @@ $.extend(cur_frm.cscript, { "modified": doc.creation, "content": doc.description}); - cur_frm.communication_view = new erpnext.CommunicationView({ + cur_frm.communication_view = new wn.views.CommunicationList({ list: comm_list, parent: wrapper, doc: doc, diff --git a/utilities/doctype/contact/contact.js b/utilities/doctype/contact/contact.js index d51c0f5887..3876ca20ae 100644 --- a/utilities/doctype/contact/contact.js +++ b/utilities/doctype/contact/contact.js @@ -14,9 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -wn.require("public/app/js/communication.js"); - -//--------- ONLOAD ------------- cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.add_fetch('customer', 'customer_name', 'customer_name'); cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name'); @@ -26,7 +23,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } cur_frm.cscript.refresh = function() { - cur_frm.communication_view = new erpnext.CommunicationView({ + cur_frm.communication_view = new wn.views.CommunicationList({ list: wn.model.get("Communication", {"contact": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, diff --git a/utilities/doctype/contact/contact_list.js b/utilities/doctype/contact/contact_list.js index bbf5bf855e..3b1b3c983d 100644 --- a/utilities/doctype/contact/contact_list.js +++ b/utilities/doctype/contact/contact_list.js @@ -20,7 +20,7 @@ wn.doclistviews['Contact'] = wn.views.ListView.extend({ data.fullname = (data.first_name || '') + (data.last_name ? ' ' + data.last_name : ''); if(!data.fullname) data.fullname = data.name; - data.fullname = repl("%(fullname)s\ + data.fullname = repl("%(name)s\ ", data); // prepare description From 64cb05c3c1c08f5399e24d0bc38cc9c9491c46d4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 29 Nov 2012 16:08:45 +0530 Subject: [PATCH 2/6] form email sending via CommunicationComposer --- support/doctype/support_ticket/support_ticket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 2d89c6e386..fdfbc1af44 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -64,7 +64,7 @@ $.extend(cur_frm.cscript, { list: comm_list, parent: wrapper, doc: doc, - email: doc.raised_by + recipients: doc.raised_by }) }, From e1e4aafd9bd9dab394a078451977d8811704511a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 29 Nov 2012 17:00:53 +0530 Subject: [PATCH 3/6] communication: check send with attach if from sidebar --- home/page/latest_updates/latest_updates.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 54292945fb..aef944e4a1 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,7 @@ erpnext.updates = [ + ["29th November 2012", [ + "EMail: Form Emails are now via Communication (with Rich Text Etc.).", + ]], ["28th November 2012", [ "Profile: Profile Settings (My Settings...) is now the Profile Form.", "Financial Analytics: Show Net Profit/Loss", From 35c017a78f18994d5a4d6a62e024d702ee7e46fa Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 30 Nov 2012 10:57:28 +0530 Subject: [PATCH 4/6] cleanup of notification control: now in boot --- .../doctype/sales_invoice/sales_invoice.js | 7 +- .../doctype/sales_invoice/sales_invoice.py | 2 - .../doctype/purchase_order/purchase_order.js | 7 +- buying/doctype/supplier/supplier.js | 9 ++- buying/doctype/supplier/supplier.py | 38 +++-------- buying/doctype/supplier/supplier.txt | 19 ++++-- hr/doctype/expense_claim/expense_claim.js | 9 +-- selling/doctype/customer/customer.js | 25 ++----- selling/doctype/customer/customer.py | 62 +++-------------- selling/doctype/customer/customer.txt | 17 ++++- selling/doctype/lead/lead.js | 1 - selling/doctype/opportunity/opportunity.js | 11 ++- selling/doctype/opportunity/opportunity.py | 32 ++++----- selling/doctype/opportunity/opportunity.txt | 18 +++-- selling/doctype/quotation/quotation.js | 19 +++--- selling/doctype/quotation/quotation.py | 5 +- selling/doctype/sales_order/sales_order.js | 7 +- .../notification_control.js | 42 +----------- .../notification_control.py | 67 ------------------- startup/event_handlers.py | 2 + stock/doctype/delivery_note/delivery_note.js | 7 +- .../purchase_receipt/purchase_receipt.js | 7 +- utilities/transaction_base.py | 10 +-- 23 files changed, 128 insertions(+), 295 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index ad774fe0e8..87d6f1ccd2 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -25,7 +25,6 @@ cur_frm.pformat.print_heading = 'Invoice'; wn.require('app/selling/doctype/sales_common/sales_common.js'); wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); // On Load // ------- @@ -506,11 +505,9 @@ cur_frm.cscript.convert_into_recurring_invoice = function(doc, dt, dn) { } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Sales Invoice', - doctype: 'Sales Invoice' + if(cint(wn.boot.notification_settings.sales_invoice)) { + cur_frm.email_doc(wn.boot.notification_settings.sales_invoice); } - cur_frm.cscript.notify(doc, args); } cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) { diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 3763abb872..aa2e52b519 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -40,11 +40,9 @@ class DocType(TransactionBase): self.tname = 'Sales Invoice Item' self.fname = 'entries' - def autoname(self): self.doc.name = make_autoname(self.doc.naming_series+ '.#####') - def set_pos_fields(self): """Set retail related fields from pos settings""" pos = webnotes.conn.sql("select * from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1) diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index 584648d31e..e31cfd77a7 100644 --- a/buying/doctype/purchase_order/purchase_order.js +++ b/buying/doctype/purchase_order/purchase_order.js @@ -21,7 +21,6 @@ cur_frm.cscript.other_fname = "purchase_tax_details"; wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('app/buying/doctype/purchase_common/purchase_common.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); cur_frm.cscript.onload = function(doc, cdt, cdn) { // set missing values in parent doc @@ -220,9 +219,7 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){ } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Purchase Order', - doctype: 'Purchase Order' + if(cint(wn.boot.notification_settings.purchase_order)) { + cur_frm.email_doc(wn.boot.notification_settings.purchase_order); } - cur_frm.cscript.notify(doc, args); } diff --git a/buying/doctype/supplier/supplier.js b/buying/doctype/supplier/supplier.js index 4fd94f562d..1b7f369a28 100644 --- a/buying/doctype/supplier/supplier.js +++ b/buying/doctype/supplier/supplier.js @@ -15,7 +15,6 @@ // along with this program. If not, see . wn.require('app/setup/doctype/contact_control/contact_control.js'); -wn.require('app/support/doctype/communication/communication.js'); cur_frm.cscript.onload = function(doc,dt,dn){ @@ -29,7 +28,6 @@ cur_frm.cscript.onload = function(doc,dt,dn){ // make contact, history list body //cur_frm.cscript.make_cl_body(); cur_frm.cscript.make_hl_body(); - cur_frm.cscript.make_communication_body(); } cur_frm.cscript.refresh = function(doc,dt,dn) { @@ -46,8 +44,13 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { // make lists cur_frm.cscript.make_address(doc,dt,dn); cur_frm.cscript.make_contact(doc,dt,dn); - cur_frm.cscript.render_communication_list(doc, cdt, cdn); cur_frm.cscript.make_history(doc,dt,dn); + + cur_frm.communication_view = new wn.views.CommunicationList({ + list: wn.model.get("Communication", {"supplier": doc.name}), + parent: cur_frm.fields_dict.communication_html.wrapper, + doc: doc + }) } } diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index d7f69d6efe..fec18afe14 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -18,26 +18,23 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add -from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, getchildren, make_autoname -from webnotes.model.wrapper import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, msgprint, errprint +from webnotes.utils import cint, cstr, get_defaults +from webnotes.model.code import get_obj +from webnotes import form, msgprint -set = webnotes.conn.set sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction convert_to_lists = webnotes.conn.convert_to_lists -# ----------------------------------------------------------------------------------------- +from utilities.transaction_base import TransactionBase -class DocType: +class DocType(TransactionBase): def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist + def onload(self): + self.add_communication_list() + def autoname(self): #get default naming conventional from control panel supp_master_name = get_defaults()['supp_master_name'] @@ -59,22 +56,17 @@ class DocType: else: self.doc.name = make_autoname(self.doc.naming_series+'.#####') - # ---------------------------------------- - # update credit days and limit in account - # ---------------------------------------- def update_credit_days_limit(self): sql("update tabAccount set credit_days = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.name + " - " + self.get_company_abbr())) - def on_update(self): if not self.doc.naming_series: self.doc.naming_series = '' - # create address addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode] address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds)) - set(self.doc,'address', address_line) + webnotes.conn.set(self.doc,'address', address_line) # create account head self.create_account_head() @@ -82,12 +74,9 @@ class DocType: # update credit days and limit in account self.update_credit_days_limit() - def check_state(self): return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)]) - # ACCOUNTS - # ------------------------------------------- def get_payables_group(self): g = sql("select payables_group from tabCompany where name=%s", self.doc.company) g = g and g[0][0] or '' @@ -116,7 +105,6 @@ class DocType: return self.doc.supplier_type + " - " + abbr - def validate(self): #validation for Naming Series mandatory field... if get_defaults()['supp_master_name'] == 'Naming Series': @@ -124,9 +112,6 @@ class DocType: msgprint("Series is Mandatory.") raise Exception - - # create accont head - in tree under zone + territory - # ------------------------------------------------------- def create_account_head(self): if self.doc.company : abbr = self.get_company_abbr() @@ -142,7 +127,6 @@ class DocType: else : msgprint("Please select Company under which you want to create account head") - def get_contacts(self,nm): if nm: contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm)) @@ -172,16 +156,12 @@ class DocType: from webnotes.model import delete_doc delete_doc('Account', acc[0][0]) - def on_trash(self): self.delete_supplier_address() self.delete_supplier_contact() self.delete_supplier_communication() self.delete_supplier_account() - - # on rename - # --------- def on_rename(self,newdn,olddn): #update supplier_name if not naming series if get_defaults().get('supp_master_name') == 'Supplier Name': diff --git a/buying/doctype/supplier/supplier.txt b/buying/doctype/supplier/supplier.txt index 833c1273b8..a46927b77e 100644 --- a/buying/doctype/supplier/supplier.txt +++ b/buying/doctype/supplier/supplier.txt @@ -2,11 +2,12 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-07-18 20:34:42", + "creation": "2012-11-02 17:17:04", "modified_by": "Administrator", - "modified": "2012-07-18 17:41:49" + "modified": "2012-11-30 10:53:32" }, { + "autoname": "naming_series:", "name": "__common__", "search_fields": "supplier_name,supplier_type", "module": "Buying", @@ -32,6 +33,16 @@ "name": "Supplier", "doctype": "DocType" }, + { + "description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts", + "oldfieldtype": "Section Break", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Basic Info", + "fieldname": "basic_info", + "fieldtype": "Section Break", + "permlevel": 0 + }, { "no_copy": 1, "oldfieldtype": "Data", @@ -124,7 +135,6 @@ }, { "doctype": "DocField", - "label": "Communication History", "fieldname": "communication_history", "fieldtype": "Section Break", "permlevel": 0 @@ -246,8 +256,7 @@ "write": 1, "role": "Purchase Master Manager", "cancel": 1, - "permlevel": 0, - "match": "" + "permlevel": 0 }, { "amend": 0, diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js index 5ed0d379b4..d890102474 100644 --- a/hr/doctype/expense_claim/expense_claim.js +++ b/hr/doctype/expense_claim/expense_claim.js @@ -100,8 +100,6 @@ cur_frm.cscript.sanctioned_amount = function(doc,cdt,cdn){ cur_frm.cscript.calculate_total(doc,cdt,cdn); } -wn.require('app/setup/doctype/notification_control/notification_control.js'); - cur_frm.cscript.approve = function(doc,cdt,cdn){ cur_frm.cscript.calculate_total(doc,cdt,cdn); @@ -248,12 +246,9 @@ cur_frm.cscript.update_voucher = function(doc){ } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Expense Claim', - doctype: 'Expense Claim', - send_to: doc.exp_approver + if(cint(wn.boot.notification_settings.expense_claim)) { + cur_frm.email_doc(wn.boot.notification_settings.expense_claim); } - cur_frm.cscript.notify(doc, args); } cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query; \ No newline at end of file diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js index 2031fe8b7b..d20b0c927d 100644 --- a/selling/doctype/customer/customer.js +++ b/selling/doctype/customer/customer.js @@ -15,9 +15,6 @@ // along with this program. If not, see . wn.require('app/setup/doctype/contact_control/contact_control.js'); -wn.require('app/support/doctype/communication/communication.js'); - -/* ********************************* onload ********************************************* */ cur_frm.cscript.onload = function(doc,dt,dn){ // history doctypes and scripts @@ -32,8 +29,6 @@ cur_frm.cscript.onload = function(doc,dt,dn){ //cur_frm.cscript.make_sl_body(); cur_frm.cscript.load_defaults(doc, dt, dn); - - cur_frm.cscript.make_communication_body(); } cur_frm.cscript.load_defaults = function(doc, dt, dn) { @@ -47,8 +42,6 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) { cur_frm.add_fetch('lead_name', 'company_name', 'customer_name'); cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate'); -/* ********************************* refresh ********************************************* */ - cur_frm.cscript.refresh = function(doc,dt,dn) { if(sys_defaults.cust_master_name == 'Customer Name') hide_field('naming_series'); @@ -57,16 +50,18 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { if(doc.__islocal){ hide_field(['address_html','contact_html']); - //cur_frm.cscript.set_hl_msg(doc); - //cur_frm.cscript.set_sl_msg(doc); }else{ unhide_field(['address_html','contact_html']); // make lists cur_frm.cscript.make_address(doc,dt,dn); cur_frm.cscript.make_contact(doc,dt,dn); cur_frm.cscript.make_history(doc,dt,dn); - cur_frm.cscript.render_communication_list(doc, cdt, cdn); - //cur_frm.cscript.make_shipping_address(doc,dt,dn); + + cur_frm.communication_view = new wn.views.CommunicationList({ + list: wn.model.get("Communication", {"customer": doc.name}), + parent: cur_frm.fields_dict.communication_html.wrapper, + doc: doc + }); } } @@ -117,11 +112,6 @@ cur_frm.cscript.make_contact = function() { } -/* ********************************* client triggers ************************************** */ - -// --------------- -// customer group -// --------------- cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) { return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50'; } @@ -130,8 +120,6 @@ cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) { cur_frm.fields_dict.lead_name.get_query = erpnext.utils.lead_query; -// Transaction History -// functions called by these functions are defined in communication.js cur_frm.cscript.make_qtn_list = function(parent, doc) { cur_frm.cscript.get_common_list_view(parent, doc, 'Quotation'); } @@ -173,7 +161,6 @@ cur_frm.cscript.get_common_list_view = function(parent, doc, doctype) { cur_frm.cscript.render_list(doc, doctype, parent, ListView); } - cur_frm.cscript.make_si_list = function(parent, doc) { var ListView = wn.views.ListView.extend({ init: function(doclistview) { diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 0bf499b57c..975dd89c79 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -18,24 +18,24 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, date_diff, flt, formatdate, get_defaults, getdate, has_common, now, nowdate, replace_newlines, sendmail, set_default, user_format, validate_email_add +from webnotes.utils import cstr, get_defaults from webnotes.model.doc import Document, make_autoname from webnotes.model.code import get_obj from webnotes import msgprint, errprint -set = webnotes.conn.set sql = webnotes.conn.sql get_value = webnotes.conn.get_value -convert_to_lists = webnotes.conn.convert_to_lists -# ----------------------------------------------------------------------------------------- +from utilities.transaction_base import TransactionBase -class DocType: +class DocType(TransactionBase): def __init__(self, doc, doclist=[]): self.doc = doc self.doclist = doclist -# ******************************************************* autoname *********************************************************** + def onload(self): + self.add_communication_list() + def autoname(self): cust_master_name = get_defaults().get('cust_master_name') if cust_master_name == 'Customer Name': @@ -53,17 +53,9 @@ class DocType: else: self.doc.name = make_autoname(self.doc.naming_series+'.#####') - -# ******************************************************* triggers *********************************************************** - # ---------------- - # get company abbr - # ----------------- def get_company_abbr(self): return get_value('Company', self.doc.company, 'abbr') - # ----------------------------------------------------------------------------------------------------- - # get parent account(i.e receivables group from company where default account head need to be created) - # ----------------------------------------------------------------------------------------------------- def get_receivables_group(self): g = sql("select receivables_group from tabCompany where name=%s", self.doc.company) g = g and g[0][0] or '' @@ -72,26 +64,15 @@ class DocType: raise Exception return g -# ******************************************************* validate ********************************************************* - # ---------------- - # validate values - # ---------------- def validate_values(self): # Master name by naming series -> Series field mandatory if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series: msgprint("Series is Mandatory.") raise Exception - # --------- - # validate - # --------- def validate(self): self.validate_values() -# ******************************************************* on update ********************************************************* - # ------------------------ - # create customer address - # ------------------------ def create_customer_address(self): addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode] address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds)) @@ -100,15 +81,11 @@ class DocType: address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1) if self.doc.email_id: address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id) - set(self.doc,'address', address_line) + webnotes.conn.set(self.doc,'address', address_line) telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " + "\n" + "(fax): " + cstr(self.doc.fax_1) - set(self.doc,'telephone',telephone) + webnotes.conn.set(self.doc,'telephone',telephone) - - # ------------------------------------ - # create primary contact for customer - # ------------------------------------ def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr): c1 = Document('Contact') c1.first_name = nm @@ -126,10 +103,6 @@ class DocType: c1.customer_group = self.doc.customer_group c1.save(1) - - # ------------------------ - # create customer contact - # ------------------------ def create_customer_contact(self): contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name)) contact = contact and contact[0][0] or '' @@ -143,18 +116,10 @@ class DocType: c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1) self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '') - - # ------------------- - # update lead status - # ------------------- def update_lead_status(self): if self.doc.lead_name: sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) - - # ------------------------------------------------------------------------- - # create accont head - in tree under receivables_group of selected company - # ------------------------------------------------------------------------- def create_account_head(self): if self.doc.company : abbr = self.get_company_abbr() @@ -167,15 +132,9 @@ class DocType: else : msgprint("Please Select Company under which you want to create account head") - - # ---------------------------------------- - # update credit days and limit in account - # ---------------------------------------- def update_credit_days_limit(self): sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.credit_limit, self.doc.name + " - " + self.get_company_abbr())) - - #create address and contact from lead def create_lead_address_contact(self): if self.doc.lead_name: details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1) @@ -211,9 +170,6 @@ class DocType: except NameError, e: pass - # ---------- - # on update - # ---------- def on_update(self): # create customer addr #self.create_customer_address() @@ -257,8 +213,6 @@ class DocType: if self.doc.lead_name: sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name) - # on rename - # --------- def on_rename(self,newdn,olddn): #update customer_name if not naming series if get_defaults().get('cust_master_name') == 'Customer Name': diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt index a20a982cf1..6b174d7f3f 100644 --- a/selling/doctype/customer/customer.txt +++ b/selling/doctype/customer/customer.txt @@ -2,11 +2,12 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-10-02 11:27:30", + "creation": "2012-11-02 17:16:46", "modified_by": "Administrator", - "modified": "2012-09-28 12:31:42" + "modified": "2012-11-30 10:54:38" }, { + "autoname": "naming_series:", "name": "__common__", "default_print_format": "Standard", "allow_print": 0, @@ -34,6 +35,17 @@ "name": "Customer", "doctype": "DocType" }, + { + "description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts", + "oldfieldtype": "Section Break", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Basic Info", + "fieldname": "basic_info", + "fieldtype": "Section Break", + "reqd": 0, + "permlevel": 0 + }, { "print_hide": 0, "no_copy": 1, @@ -183,7 +195,6 @@ }, { "doctype": "DocField", - "label": "Communication History", "fieldname": "communication_history", "fieldtype": "Section Break", "permlevel": 0 diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 081a57a0fd..0c5bf87cdb 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -73,7 +73,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { doc: doc, email: doc.email_id }) - } diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index a7290928d7..3da2ac88bb 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -15,7 +15,6 @@ // along with this program. If not, see . wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/support/doctype/communication/communication.js'); cur_frm.cscript.refresh = function(doc, cdt, cdn){ erpnext.hide_naming_series(); @@ -26,7 +25,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){ cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']); cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); } - if(!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); } // ONLOAD @@ -48,7 +46,14 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { } } - cur_frm.cscript.make_communication_body(); + if(!doc.__islocal) { + cur_frm.communication_view = new wn.views.CommunicationList({ + list: wn.model.get("Communication", {"opportunity": doc.name}), + parent: cur_frm.fields_dict.communication_html.wrapper, + doc: doc, + email: doc.contact_email + }); + } if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) { cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query; diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py index 398418adf3..4f10c80431 100644 --- a/selling/doctype/opportunity/opportunity.py +++ b/selling/doctype/opportunity/opportunity.py @@ -18,21 +18,15 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add +from webnotes.utils import add_days, add_years, cint, cstr, date_diff, flt, getdate from webnotes.model import db_exists -from webnotes.model.doc import Document, addchild, getchildren, make_autoname -from webnotes.model.wrapper import getlist, copy_doclist -from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax -from webnotes import session, form, msgprint, errprint +from webnotes.model.doc import Document, addchild, make_autoname +from webnotes.model.wrapper import getlist +from webnotes.model.code import get_obj +from webnotes import form, msgprint -set = webnotes.conn.set sql = webnotes.conn.sql -get_value = webnotes.conn.get_value -in_transaction = webnotes.conn.in_transaction -convert_to_lists = webnotes.conn.convert_to_lists -# ----------------------------------------------------------------------------------------- - from utilities.transaction_base import TransactionBase class DocType(TransactionBase): @@ -42,8 +36,8 @@ class DocType(TransactionBase): self.fname = 'enq_details' self.tname = 'Opportunity Item' - def autoname(self): - self.doc.name = make_autoname(self.doc.naming_series+'.####') + def onload(self): + self.add_communication_list() def get_item_details(self, item_code): item = sql("""select item_name, stock_uom, description_html, description, item_group, brand @@ -94,8 +88,8 @@ class DocType(TransactionBase): if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date: if self.doc.contact_by: self.add_calendar_event() - set(self.doc, 'contact_date_ref',self.doc.contact_date) - set(self.doc, 'status', 'Draft') + webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date) + webnotes.conn.set(self.doc, 'status', 'Draft') def add_calendar_event(self): desc='' @@ -169,7 +163,7 @@ class DocType(TransactionBase): self.validate_lead_cust() def on_submit(self): - set(self.doc, 'status', 'Submitted') + webnotes.conn.set(self.doc, 'status', 'Submitted') def on_cancel(self): chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name) @@ -177,7 +171,7 @@ class DocType(TransactionBase): msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus can not be cancelled.") raise Exception else: - set(self.doc, 'status', 'Cancelled') + webnotes.conn.set(self.doc, 'status', 'Cancelled') def declare_enquiry_lost(self,arg): chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name) @@ -185,6 +179,6 @@ class DocType(TransactionBase): msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus 'Opportunity Lost' can not be declared against it.") raise Exception else: - set(self.doc, 'status', 'Opportunity Lost') - set(self.doc, 'order_lost_reason', arg) + webnotes.conn.set(self.doc, 'status', 'Opportunity Lost') + webnotes.conn.set(self.doc, 'order_lost_reason', arg) return 'true' diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt index f89a5d2271..575cc10392 100644 --- a/selling/doctype/opportunity/opportunity.txt +++ b/selling/doctype/opportunity/opportunity.txt @@ -2,12 +2,13 @@ { "owner": "Administrator", "docstatus": 0, - "creation": "2012-11-28 11:26:19", + "creation": "2012-11-24 17:21:44", "modified_by": "Administrator", - "modified": "2012-11-16 12:27:49" + "modified": "2012-11-30 10:54:00" }, { "is_submittable": 1, + "autoname": "naming_series:", "name": "__common__", "default_print_format": "Standard", "search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company", @@ -34,6 +35,16 @@ "name": "Opportunity", "doctype": "DocType" }, + { + "description": "Enter customer enquiry for which you might raise a quotation in future", + "oldfieldtype": "Section Break", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Basic Info", + "fieldname": "basic_info", + "fieldtype": "Section Break", + "permlevel": 0 + }, { "description": "To manage multiple series please go to Setup > Manage Series", "no_copy": 1, @@ -154,15 +165,14 @@ "oldfieldtype": "Section Break", "colour": "White:FFF", "doctype": "DocField", - "label": "Communication History", "fieldname": "communication_history", "fieldtype": "Section Break", "permlevel": 0 }, { - "allow_on_submit": 1, "oldfieldtype": "Table", "colour": "White:FFF", + "allow_on_submit": 1, "doctype": "DocField", "label": "Communication HTML", "oldfieldname": "follow_up", diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index e6299754f8..1b03781b5b 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -24,8 +24,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('app/selling/doctype/sales_common/sales_common.js'); wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); -wn.require('app/support/doctype/communication/communication.js'); // ONLOAD // =================================================================================== @@ -49,7 +47,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']); } } - cur_frm.cscript.make_communication_body(); + //cur_frm.cscript.make_communication_body(); if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) { cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query; @@ -104,7 +102,14 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.customer || doc.lead) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true); else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false); - if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); + if (!doc.__islocal) { + cur_frm.communication_view = new wn.views.CommunicationList({ + list: wn.model.get("Communication", {"quotation": doc.name}), + parent: cur_frm.fields_dict.communication_html.wrapper, + doc: doc, + email: doc.contact_email + }); + } } @@ -333,9 +338,7 @@ cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Quotation', - doctype: 'Quotation' + if(cint(wn.boot.notification_settings.quotation)) { + cur_frm.email_doc(wn.boot.notification_settings.quotation_message); } - cur_frm.cscript.notify(doc, args); } \ No newline at end of file diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index 76b1ef6b93..cef0abee23 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -41,7 +41,10 @@ class DocType(TransactionBase): self.doclist = doclist self.tname = 'Quotation Item' self.fname = 'quotation_details' - + + def onload(self): + self.add_communication_list() + # Pull Opportunity Details # -------------------- def pull_enq_details(self): diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js index f720cfa657..6a3dfc4af8 100644 --- a/selling/doctype/sales_order/sales_order.js +++ b/selling/doctype/sales_order/sales_order.js @@ -25,7 +25,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('app/selling/doctype/sales_common/sales_common.js'); wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); // ONLOAD @@ -369,9 +368,7 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Sales Order', - doctype: 'Sales Order' + if(cint(wn.boot.notification_settings.sales_order)) { + cur_frm.email_doc(wn.boot.notification_settings.sales_order); } - cur_frm.cscript.notify(doc, args); } diff --git a/setup/doctype/notification_control/notification_control.js b/setup/doctype/notification_control/notification_control.js index b52520a5a7..619d417379 100644 --- a/setup/doctype/notification_control/notification_control.js +++ b/setup/doctype/notification_control/notification_control.js @@ -22,45 +22,5 @@ cur_frm.cscript.select_transaction = function(doc, cdt, cdn) { refresh_field('custom_message'); } $c_obj(make_doclist(cdt, cdn),'get_message',doc.select_transaction, callback) -} -} - -cur_frm.cscript.notify = function(doc, args) { - var doc = locals[doc.doctype][doc.name]; - $c_obj(make_doclist(doc.doctype, doc.name), 'get_formatted_message', { - type: args['type'], - doctype: args['doctype'], - contact_name: args['contact_name'] || doc.contact_display - }, function(r, rt) { - if(!r.exc) { - var res = JSON.parse(r.message); - var send_from = (function() { - if(user!='Administrator') { - return user; - } else { - return (wn.control_panel.auto_email_id || - 'ERPNext Notification'); - } - })(); - if(res.send) { - var print_heading = (doc.select_print_heading || args['type']) - if(validate_email(args['send_to'] || doc.contact_email || '')) { - sendmail( - args['send_to'] || doc.contact_email, - send_from, - send_from, - doc.company + " - " + print_heading + " - " + doc.name, - res.message, - res.print_format - ); - msgprint('This ' + print_heading + ' is being sent to ' - + (args['send_to'] || doc.contact_email) + '
...'); - } else { - msgprint('Invalid/Missing Email Address of Contact. Auto notification for ' - + print_heading + ' not sent.'); - } - } - } - //console.log(JSON.parse(r.message)); - }); + } } diff --git a/setup/doctype/notification_control/notification_control.py b/setup/doctype/notification_control/notification_control.py index f8b0ee2ad5..b40ba6e2b0 100644 --- a/setup/doctype/notification_control/notification_control.py +++ b/setup/doctype/notification_control/notification_control.py @@ -25,84 +25,17 @@ from webnotes import msgprint sql = webnotes.conn.sql -# ----------------------------------------------------------------------------------------- -# Notification control class DocType: def __init__(self,d,dl): self.doc, self.doclist = d,dl - # get message to load in custom text - # ---------------------------------- def get_message(self, arg): fn = arg.lower().replace(' ', '_') + '_message' v = sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control')) return v and v[0][0] or '' - # set custom text - # --------------- def set_message(self, arg = ''): fn = self.doc.select_transaction.lower().replace(' ', '_') + '_message' webnotes.conn.set(self.doc, fn, self.doc.custom_message) msgprint("Custom Message for %s updated!" % self.doc.select_transaction) - - def get_formatted_message(self, args): - """ - args can contain: - * type - * doctype - * contact_name - """ - import json - args = json.loads(args) - res = { - 'send': 0, - 'message': self.prepare_message(args), - 'print_format': self.get_default_print_format(args) - } - - dt_small = args.get('doctype').replace(' ', '_').lower() - if cint(self.doc.fields.get(dt_small)): - res['send'] = 1 - - return json.dumps(res) - - - def prepare_message(self, args): - """ - Prepares message body - """ - if args.get('type'): - msg_dict = {} - msg_dict['message'] = args.get('message') or self.get_message(args.get('type')) - msg_dict['company'] = Document('Control Panel', 'Control Panel').company_name - msg_dict['salutation'] = "Hi" + (args.get('contact_name') and (" " + args.get('contact_name')) or "") - msg_dict['send_from'] = webnotes.conn.sql("""\ - SELECT CONCAT_WS(' ', first_name, last_name) - FROM `tabProfile` - WHERE name = %s""", webnotes.session['user'], as_list=1)[0][0] or '' - - return """\ -
- %(salutation)s, - - %(message)s - - Thanks, - %(send_from)s - %(company)s -
""" % msg_dict - - else: return "" - - - def get_default_print_format(self, args): - """ - Get default print format from doclayer - """ - doclayer = get_obj('Customize Form', 'Customize Form') - doclayer.doc.doc_type = args.get('doctype') - doclayer.get() - if doclayer.doc.default_print_format: - return doclayer.doc.default_print_format - else: return 'Standard' diff --git a/startup/event_handlers.py b/startup/event_handlers.py index 7d1f5847c0..07205b8814 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -76,6 +76,8 @@ def boot_session(bootinfo): import webnotes.model.doctype bootinfo['docs'] += webnotes.model.doctype.get('Event') bootinfo['docs'] += webnotes.model.doctype.get('Search Criteria') + bootinfo['notification_settings'] = webnotes.doc("Notification Control", + "Notification Control").get_values() bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 4a3910abec..62958112a1 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -23,7 +23,6 @@ cur_frm.cscript.sales_team_fname = "sales_team"; wn.require('app/selling/doctype/sales_common/sales_common.js'); wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); // ONLOAD // ================================================================================================ @@ -327,9 +326,7 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){ } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Delivery Note', - doctype: 'Delivery Note' + if(cint(wn.boot.notification_settings.delivery_note)) { + cur_frm.email_doc(wn.boot.notification_settings.delivery_note); } - cur_frm.cscript.notify(doc, args); } \ No newline at end of file diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index b9433147a8..0ab6681bb8 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -21,7 +21,6 @@ cur_frm.cscript.other_fname = "purchase_tax_details"; wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js'); wn.require('app/buying/doctype/purchase_common/purchase_common.js'); wn.require('app/utilities/doctype/sms_control/sms_control.js'); -wn.require('app/setup/doctype/notification_control/notification_control.js'); //========================== On Load ================================================================ cur_frm.cscript.onload = function(doc, cdt, cdn) { @@ -311,9 +310,7 @@ cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){ } cur_frm.cscript.on_submit = function(doc, cdt, cdn) { - var args = { - type: 'Purchase Receipt', - doctype: 'Purchase Receipt' + if(cint(wn.boot.notification_settings.purchase_receipt)) { + cur_frm.email_doc(wn.boot.notification_settings.purchase_receipt); } - cur_frm.cscript.notify(doc, args); } diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 398a831d30..37b818e08c 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -238,10 +238,12 @@ class TransactionBase: return dcc - def get_formatted_message(self, args): - """ get formatted message for auto notification""" - return get_obj('Notification Control').get_formatted_message(args) - + def load_notification_message(self): + dt = self.doc.doctype.lower().replace(" ", "_") + if int(webnotes.conn.get_value("Notification Control", None, dt) or 0): + self.doc.fields["__notification_message"] = \ + webnotes.conn.get_value("Notification Control", None, dt + "_message") + def add_communication_list(self): # remove communications if present self.doclist = webnotes.doclist(self.doclist).get({ From 86adcaa113dfb4f1fe46bee3e6cb5d4e8b9e0b63 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 30 Nov 2012 12:02:00 +0530 Subject: [PATCH 5/6] fixed employee permissions, fixed bug in import_merge of timestamps --- home/page/latest_updates/latest_updates.js | 3 + hr/doctype/employee/employee.py | 3 + hr/doctype/employee/employee.txt | 1944 ++++++++--------- .../employee_external_work_history.txt | 191 +- .../add_employee_field_in_employee.py | 6 + patches/patch_list.py | 4 + 6 files changed, 966 insertions(+), 1185 deletions(-) create mode 100644 patches/november_2012/add_employee_field_in_employee.py diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index aef944e4a1..c47a6fd0d3 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,4 +1,7 @@ erpnext.updates = [ + ["30th November 2012", [ + "Auto Notifications: System will prompt user with pre-set message for auto-notification.", + ]], ["29th November 2012", [ "EMail: Form Emails are now via Communication (with Rich Text Etc.).", ]], diff --git a/hr/doctype/employee/employee.py b/hr/doctype/employee/employee.py index 0be68306f1..e65258fe57 100644 --- a/hr/doctype/employee/employee.py +++ b/hr/doctype/employee/employee.py @@ -37,6 +37,8 @@ class DocType: self.doc.name = make_autoname(self.doc.naming_series + '.####') elif ret[0][0]=='Employee Number': self.doc.name = make_autoname(self.doc.employee_number) + + self.doc.employee = self.doc.name def get_retirement_date(self): import datetime @@ -51,6 +53,7 @@ class DocType: return ret_sal_struct and ret_sal_struct[0][0] or '' def validate(self): + self.doc.employee = self.doc.name self.validate_date() self.validate_email() self.validate_name() diff --git a/hr/doctype/employee/employee.txt b/hr/doctype/employee/employee.txt index f780836ce8..826df842d2 100644 --- a/hr/doctype/employee/employee.txt +++ b/hr/doctype/employee/employee.txt @@ -1,1069 +1,879 @@ -# DocType, Employee [ - - # These values are common in all dictionaries - { - u'creation': '2012-07-03 13:30:40', - u'docstatus': 0, - u'modified': '2012-11-14 16:54:18', - u'modified_by': u'Administrator', - u'owner': u'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': u'1308918132', - 'allow_attach': 1, - 'allow_trash': 1, - 'colour': u'White:FFF', - u'doctype': u'DocType', - 'document_type': u'Master', - 'module': u'HR', - u'name': u'__common__', - 'search_fields': u'employee_name', - 'section_style': u'Tabbed', - 'server_code_error': u' ', - 'show_in_menu': 0, - 'subject': u'%(employee_name)s', - 'tag_fields': u'status', - 'version': 1 - }, - - # These values are common for all DocField - { - u'doctype': u'DocField', - u'name': u'__common__', - 'parent': u'Employee', - 'parentfield': u'fields', - 'parenttype': u'DocType' - }, - - # These values are common for all DocPerm - { - u'doctype': u'DocPerm', - u'name': u'__common__', - 'parent': u'Employee', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'read': 1 - }, - - # DocType, Employee - { - u'doctype': u'DocType', - u'name': u'Employee' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'basic_information', - 'fieldtype': u'Section Break', - 'label': u'Basic Information', - 'oldfieldtype': u'Section Break', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break0', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'To setup, please go to Setup > Naming Series', - u'doctype': u'DocField', - 'fieldname': u'naming_series', - 'fieldtype': u'Select', - 'label': u'Naming Series', - 'no_copy': 1, - 'oldfieldname': u'naming_series', - 'oldfieldtype': u'Select', - 'options': u'EMP/', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'salutation', - 'fieldtype': u'Select', - 'label': u'Salutation', - 'oldfieldname': u'salutation', - 'oldfieldtype': u'Select', - 'options': u'\nMr\nMs', - 'permlevel': 0, - 'search_index': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'employee_name', - 'fieldtype': u'Data', - 'label': u'Full Name', - 'oldfieldname': u'employee_name', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'reqd': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'employee_number', - 'fieldtype': u'Data', - 'in_filter': 1, - 'label': u'Employee Number', - 'oldfieldname': u'employee_number', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'search_index': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'System User (login) ID. If set, it will become default for all HR forms.', - u'doctype': u'DocField', - 'fieldname': u'user_id', - 'fieldtype': u'Link', - 'label': u'User ID', - 'options': u'Profile', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break1', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'date_of_joining', - 'fieldtype': u'Date', - 'label': u'Date of Joining', - 'oldfieldname': u'date_of_joining', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'reqd': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'date_of_birth', - 'fieldtype': u'Date', - 'in_filter': 1, - 'label': u'Date of Birth', - 'oldfieldname': u'date_of_birth', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0, - 'trigger': u'Client' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'gender', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Gender', - 'oldfieldname': u'gender', - 'oldfieldtype': u'Select', - 'options': u'\nMale\nFemale', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'company', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Company', - 'options': u'link:Company', - 'permlevel': 0, - 'print_hide': 1, - 'reqd': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'employment_details', - 'fieldtype': u'Section Break', - 'label': u'Employment Details', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'col_break_21', - 'fieldtype': u'Column Break', - 'permlevel': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'Active', - u'doctype': u'DocField', - 'fieldname': u'status', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Status', - 'oldfieldname': u'status', - 'oldfieldtype': u'Select', - 'options': u'\nActive\nLeft', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'employment_type', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Employment Type', - 'oldfieldname': u'employment_type', - 'oldfieldtype': u'Link', - 'options': u'Employment Type', - 'permlevel': 0, - 'search_index': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Applicable Holiday List', - u'doctype': u'DocField', - 'fieldname': u'holiday_list', - 'fieldtype': u'Link', - 'label': u'Holiday List', - 'oldfieldname': u'holiday_list', - 'oldfieldtype': u'Link', - 'options': u'Holiday List', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'col_break_22', - 'fieldtype': u'Column Break', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'scheduled_confirmation_date', - 'fieldtype': u'Date', - 'in_filter': 1, - 'label': u'Scheduled Confirmation Date', - 'oldfieldname': u'scheduled_confirmation_date', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'search_index': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'final_confirmation_date', - 'fieldtype': u'Date', - 'label': u'Final Confirmation Date', - 'oldfieldname': u'final_confirmation_date', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'search_index': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'contract_end_date', - 'fieldtype': u'Date', - 'in_filter': 1, - 'label': u'Contract End Date', - 'oldfieldname': u'contract_end_date', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'search_index': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'date_of_retirement', - 'fieldtype': u'Date', - 'label': u'Date Of Retirement', - 'oldfieldname': u'date_of_retirement', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'job_profile', - 'fieldtype': u'Section Break', - 'label': u'Job Profile', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break2', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'branch', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Branch', - 'oldfieldname': u'branch', - 'oldfieldtype': u'Link', - 'options': u'Branch', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'department', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Department', - 'oldfieldname': u'department', - 'oldfieldtype': u'Link', - 'options': u'Department', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'designation', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Designation', - 'oldfieldname': u'designation', - 'oldfieldtype': u'Link', - 'options': u'Designation', - 'permlevel': 0, - 'reqd': 0, - 'search_index': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'grade', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Grade', - 'oldfieldname': u'grade', - 'oldfieldtype': u'Link', - 'options': u'Grade', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'reports_to', - 'fieldtype': u'Link', - 'label': u'Reports to', - 'oldfieldname': u'reports_to', - 'oldfieldtype': u'Link', - 'options': u'Employee', - 'permlevel': 0 - }, - - # DocField - { - 'description': u'Provide email id registered in company', - u'doctype': u'DocField', - 'fieldname': u'company_email', - 'fieldtype': u'Data', - 'in_filter': 1, - 'label': u'Email (By company)', - 'oldfieldname': u'company_email', - 'oldfieldtype': u'Data', - 'permlevel': 0, - 'reqd': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'salary_information', - 'fieldtype': u'Column Break', - 'label': u'Salary Information', - 'oldfieldtype': u'Section Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'salary_mode', - 'fieldtype': u'Select', - 'label': u'Salary Mode', - 'oldfieldname': u'salary_mode', - 'oldfieldtype': u'Select', - 'options': u'\nBank\nCash\nCheque', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u"eval:doc.salary_mode == 'Bank'", - u'doctype': u'DocField', - 'fieldname': u'bank_name', - 'fieldtype': u'Data', - 'hidden': 0, - 'in_filter': 1, - 'label': u'Bank Name', - 'oldfieldname': u'bank_name', - 'oldfieldtype': u'Link', - 'options': u'Suggest', - 'permlevel': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'depends_on': u"eval:doc.salary_mode == 'Bank'", - u'doctype': u'DocField', - 'fieldname': u'bank_ac_no', - 'fieldtype': u'Data', - 'hidden': 0, - 'label': u'Bank A/C No.', - 'oldfieldname': u'bank_ac_no', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'esic_card_no', - 'fieldtype': u'Data', - 'label': u'ESIC CARD No', - 'oldfieldname': u'esic_card_no', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'pf_number', - 'fieldtype': u'Data', - 'label': u'PF Number', - 'oldfieldname': u'pf_number', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'gratuity_lic_id', - 'fieldtype': u'Data', - 'label': u'Gratuity LIC ID', - 'oldfieldname': u'gratuity_lic_id', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'contact_details', - 'fieldtype': u'Section Break', - 'label': u'Contact Details', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break3', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'cell_number', - 'fieldtype': u'Data', - 'label': u'Cell Number', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'personal_email', - 'fieldtype': u'Data', - 'label': u'Personal Email', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'notice_number_of_days', - 'fieldtype': u'Int', - 'label': u'Notice - Number of Days', - 'oldfieldname': u'notice_number_of_days', - 'oldfieldtype': u'Int', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'emergency_contact_details', - 'fieldtype': u'HTML', - 'label': u'Emergency Contact Details', - 'options': u'Emergency Contact Details', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'person_to_be_contacted', - 'fieldtype': u'Data', - 'label': u'Person To Be Contacted', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'relation', - 'fieldtype': u'Data', - 'label': u'Relation', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'emergency_phone_number', - 'fieldtype': u'Data', - 'label': u'Emergency Phone Number', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break4', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'permanent_accommodation_type', - 'fieldtype': u'Select', - 'label': u'Permanent Accommodation Type', - 'options': u'\nRented\nOwned', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'permanent_address', - 'fieldtype': u'Small Text', - 'label': u'Permanent Address', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'current_accommodation_type', - 'fieldtype': u'Select', - 'label': u'Current Accommodation Type', - 'options': u'\nRented\nOwned', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'current_address', - 'fieldtype': u'Small Text', - 'label': u'Current Address', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'personal_details', - 'fieldtype': u'Section Break', - 'label': u'Personal Details', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break5', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'pan_number', - 'fieldtype': u'Data', - 'label': u'PAN Number', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'passport_number', - 'fieldtype': u'Data', - 'label': u'Passport Number', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'date_of_issue', - 'fieldtype': u'Date', - 'label': u'Date of Issue', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'valid_upto', - 'fieldtype': u'Date', - 'label': u'Valid Upto', - 'permlevel': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'salary_structure', - 'fieldtype': u'Button', - 'hidden': 1, - 'label': u'Salary Structure', - 'oldfieldtype': u'Button', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'place_of_issue', - 'fieldtype': u'Data', - 'label': u'Place of Issue', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'marital_status', - 'fieldtype': u'Select', - 'label': u'Marital Status', - 'options': u'\nSingle\nMarried\nDivorced\nWidowed', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'blood_group', - 'fieldtype': u'Select', - 'label': u'Blood Group', - 'options': u'\nA+\nA-\nB+\nB-\nAB+\nAB-\nO+\nO-', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break6', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Here you can maintain family details like name and occupation of parent, spouse and children', - u'doctype': u'DocField', - 'fieldname': u'family_background', - 'fieldtype': u'Small Text', - 'label': u'Family Background', - 'permlevel': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Here you can maintain height, weight, allergies, medical concerns etc', - u'doctype': u'DocField', - 'fieldname': u'health_details', - 'fieldtype': u'Small Text', - 'label': u'Health Details', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'educational_qualification', - 'fieldtype': u'Section Break', - 'label': u'Educational Qualification', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'educational_qualification_details', - 'fieldtype': u'Table', - 'label': u'Educational Qualification Details', - 'options': u'Employee Education', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'career_history', - 'fieldtype': u'Section Break', - 'label': u'Career History', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'previous_work_experience', - 'fieldtype': u'Section Break', - 'label': u'Previous Work Experience', - 'options': u'Simple', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'previous_experience_details', - 'fieldtype': u'Table', - 'label': u'Employee External Work History', - 'options': u'Employee External Work History', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'history_in_company', - 'fieldtype': u'Section Break', - 'label': u'History In Company', - 'options': u'Simple', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'experience_in_company_details', - 'fieldtype': u'Table', - 'label': u'Employee Internal Work Historys', - 'options': u'Employee Internal Work History', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'exit', - 'fieldtype': u'Section Break', - 'label': u'Exit', - 'oldfieldtype': u'Section Break', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break7', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'resignation_letter_date', - 'fieldtype': u'Date', - 'label': u'Resignation Letter Date', - 'oldfieldname': u'resignation_letter_date', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'relieving_date', - 'fieldtype': u'Date', - 'in_filter': 1, - 'label': u'Relieving Date', - 'oldfieldname': u'relieving_date', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'reason_for_leaving', - 'fieldtype': u'Data', - 'label': u'Reason for Leaving', - 'oldfieldname': u'reason_for_leaving', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'leave_encashed', - 'fieldtype': u'Select', - 'label': u'Leave Encashed?', - 'oldfieldname': u'leave_encashed', - 'oldfieldtype': u'Select', - 'options': u'\nYes\nNo', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'encashment_date', - 'fieldtype': u'Date', - 'label': u'Encashment Date', - 'oldfieldname': u'encashment_date', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'exit_interview_details', - 'fieldtype': u'Column Break', - 'label': u'Exit Interview Details', - 'oldfieldname': u'col_brk6', - 'oldfieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'held_on', - 'fieldtype': u'Date', - 'label': u'Held On', - 'oldfieldname': u'held_on', - 'oldfieldtype': u'Date', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'reason_for_resignation', - 'fieldtype': u'Select', - 'label': u'Reason for Resignation', - 'oldfieldname': u'reason_for_resignation', - 'oldfieldtype': u'Select', - 'options': u'\nBetter Prospects\nHealth Concerns', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'new_workplace', - 'fieldtype': u'Data', - 'label': u'New Workplace', - 'oldfieldname': u'new_workplace', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'feedback', - 'fieldtype': u'Small Text', - 'label': u'Feedback', - 'oldfieldname': u'feedback', - 'oldfieldtype': u'Text', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'file_list', - 'fieldtype': u'Text', - 'hidden': 1, - 'label': u'File List', - 'permlevel': 0, - 'print_hide': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'trash_reason', - 'fieldtype': u'Small Text', - 'label': u'Trash Reason', - 'oldfieldname': u'trash_reason', - 'oldfieldtype': u'Small Text', - 'permlevel': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Employee', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Employee', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All' - }, - - # DocPerm - { - 'cancel': 1, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR User', - 'write': 1 - }, - - # DocPerm - { - 'cancel': 1, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR Manager', - 'write': 1 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR User' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR Manager' - } + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-11-30 11:49:12", + "modified_by": "Administrator", + "modified": "2012-11-30 11:54:31" + }, + { + "autoname": "naming_series:", + "allow_attach": 1, + "search_fields": "employee_name", + "module": "HR", + "doctype": "DocType", + "document_type": "Master", + "name": "__common__" + }, + { + "name": "__common__", + "parent": "Employee", + "doctype": "DocField", + "parenttype": "DocType", + "parentfield": "fields" + }, + { + "name": "__common__", + "parent": "Employee", + "amend": 0, + "submit": 0, + "doctype": "DocPerm", + "read": 1, + "parenttype": "DocType", + "parentfield": "permissions" + }, + { + "name": "Employee", + "doctype": "DocType" + }, + { + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Basic Information", + "fieldname": "basic_information", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 1, + "colour": "White:FFF", + "doctype": "DocField", + "label": "Employee", + "fieldname": "employee", + "fieldtype": "Data", + "hidden": 1, + "permlevel": 0, + "report_hide": 1 + }, + { + "description": "To setup, please go to Setup > Naming Series", + "no_copy": 1, + "oldfieldtype": "Select", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Naming Series", + "oldfieldname": "naming_series", + "permlevel": 0, + "fieldname": "naming_series", + "fieldtype": "Select", + "reqd": 0, + "options": "EMP/" + }, + { + "oldfieldtype": "Select", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Salutation", + "oldfieldname": "salutation", + "trigger": "Client", + "fieldname": "salutation", + "fieldtype": "Select", + "search_index": 0, + "options": "\nMr\nMs", + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Full Name", + "oldfieldname": "employee_name", + "fieldname": "employee_name", + "fieldtype": "Data", + "reqd": 1, + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Employee Number", + "oldfieldname": "employee_number", + "fieldname": "employee_number", + "fieldtype": "Data", + "search_index": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "description": "System User (login) ID. If set, it will become default for all HR forms.", + "colour": "White:FFF", + "doctype": "DocField", + "label": "User ID", + "options": "Profile", + "fieldname": "user_id", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Date of Joining", + "oldfieldname": "date_of_joining", + "fieldname": "date_of_joining", + "fieldtype": "Date", + "reqd": 1, + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Date of Birth", + "oldfieldname": "date_of_birth", + "trigger": "Client", + "fieldname": "date_of_birth", + "fieldtype": "Date", + "search_index": 0, + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Gender", + "oldfieldname": "gender", + "options": "\nMale\nFemale", + "fieldname": "gender", + "fieldtype": "Select", + "search_index": 0, + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "print_hide": 1, + "doctype": "DocField", + "label": "Company", + "options": "link:Company", + "fieldname": "company", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "doctype": "DocField", + "label": "Employment Details", + "fieldname": "employment_details", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "fieldname": "col_break_21", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "default": "Active", + "oldfieldtype": "Select", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Status", + "oldfieldname": "status", + "permlevel": 0, + "fieldname": "status", + "fieldtype": "Select", + "search_index": 1, + "reqd": 1, + "options": "\nActive\nLeft", + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Employment Type", + "oldfieldname": "employment_type", + "options": "Employment Type", + "fieldname": "employment_type", + "fieldtype": "Link", + "search_index": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "description": "Applicable Holiday List", + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Holiday List", + "oldfieldname": "holiday_list", + "options": "Holiday List", + "fieldname": "holiday_list", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "doctype": "DocField", + "fieldname": "col_break_22", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Scheduled Confirmation Date", + "oldfieldname": "scheduled_confirmation_date", + "fieldname": "scheduled_confirmation_date", + "fieldtype": "Date", + "search_index": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Date", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Final Confirmation Date", + "oldfieldname": "final_confirmation_date", + "fieldname": "final_confirmation_date", + "fieldtype": "Date", + "search_index": 0, + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Contract End Date", + "oldfieldname": "contract_end_date", + "fieldname": "contract_end_date", + "fieldtype": "Date", + "search_index": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Date Of Retirement", + "oldfieldname": "date_of_retirement", + "fieldname": "date_of_retirement", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Job Profile", + "fieldname": "job_profile", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break2", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Branch", + "oldfieldname": "branch", + "options": "Branch", + "fieldname": "branch", + "fieldtype": "Link", + "reqd": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Department", + "oldfieldname": "department", + "options": "Department", + "fieldname": "department", + "fieldtype": "Link", + "reqd": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Designation", + "oldfieldname": "designation", + "permlevel": 0, + "fieldname": "designation", + "fieldtype": "Link", + "search_index": 1, + "reqd": 0, + "options": "Designation", + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Grade", + "oldfieldname": "grade", + "options": "Grade", + "fieldname": "grade", + "fieldtype": "Link", + "reqd": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Reports to", + "oldfieldname": "reports_to", + "options": "Employee", + "fieldname": "reports_to", + "fieldtype": "Link", + "permlevel": 0 + }, + { + "description": "Provide email id registered in company", + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Email (By company)", + "oldfieldname": "company_email", + "fieldname": "company_email", + "fieldtype": "Data", + "reqd": 0, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Salary Information", + "width": "50%", + "fieldname": "salary_information", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Select", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Salary Mode", + "oldfieldname": "salary_mode", + "trigger": "Client", + "fieldname": "salary_mode", + "fieldtype": "Select", + "options": "\nBank\nCash\nCheque", + "permlevel": 0 + }, + { + "oldfieldtype": "Link", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Bank Name", + "oldfieldname": "bank_name", + "permlevel": 0, + "fieldname": "bank_name", + "fieldtype": "Data", + "depends_on": "eval:doc.salary_mode == 'Bank'", + "hidden": 0, + "options": "Suggest", + "in_filter": 1 + }, + { + "oldfieldtype": "Data", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Bank A/C No.", + "oldfieldname": "bank_ac_no", + "fieldname": "bank_ac_no", + "fieldtype": "Data", + "depends_on": "eval:doc.salary_mode == 'Bank'", + "hidden": 0, + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "ESIC CARD No", + "oldfieldname": "esic_card_no", + "fieldname": "esic_card_no", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "PF Number", + "oldfieldname": "pf_number", + "fieldname": "pf_number", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Gratuity LIC ID", + "oldfieldname": "gratuity_lic_id", + "fieldname": "gratuity_lic_id", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Contact Details", + "fieldname": "contact_details", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break3", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Cell Number", + "fieldname": "cell_number", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Personal Email", + "fieldname": "personal_email", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "oldfieldtype": "Int", + "doctype": "DocField", + "label": "Notice - Number of Days", + "oldfieldname": "notice_number_of_days", + "fieldname": "notice_number_of_days", + "fieldtype": "Int", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Emergency Contact Details", + "options": "Emergency Contact Details", + "fieldname": "emergency_contact_details", + "fieldtype": "HTML", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Person To Be Contacted", + "fieldname": "person_to_be_contacted", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Relation", + "fieldname": "relation", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Emergency Phone Number", + "fieldname": "emergency_phone_number", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break4", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Permanent Accommodation Type", + "options": "\nRented\nOwned", + "fieldname": "permanent_accommodation_type", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Permanent Address", + "fieldname": "permanent_address", + "fieldtype": "Small Text", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Current Accommodation Type", + "options": "\nRented\nOwned", + "fieldname": "current_accommodation_type", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Current Address", + "fieldname": "current_address", + "fieldtype": "Small Text", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Personal Details", + "fieldname": "personal_details", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break5", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "PAN Number", + "fieldname": "pan_number", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Passport Number", + "fieldname": "passport_number", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Date of Issue", + "fieldname": "date_of_issue", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Valid Upto", + "fieldname": "valid_upto", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "oldfieldtype": "Button", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Salary Structure", + "trigger": "Client", + "fieldname": "salary_structure", + "fieldtype": "Button", + "hidden": 1, + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Place of Issue", + "fieldname": "place_of_issue", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Marital Status", + "options": "\nSingle\nMarried\nDivorced\nWidowed", + "fieldname": "marital_status", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Blood Group", + "options": "\nA+\nA-\nB+\nB-\nAB+\nAB-\nO+\nO-", + "fieldname": "blood_group", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break6", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "description": "Here you can maintain family details like name and occupation of parent, spouse and children", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Family Background", + "fieldname": "family_background", + "fieldtype": "Small Text", + "permlevel": 0 + }, + { + "description": "Here you can maintain height, weight, allergies, medical concerns etc", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Health Details", + "fieldname": "health_details", + "fieldtype": "Small Text", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Educational Qualification", + "fieldname": "educational_qualification", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Educational Qualification Details", + "options": "Employee Education", + "fieldname": "educational_qualification_details", + "fieldtype": "Table", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Career History", + "fieldname": "career_history", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Previous Work Experience", + "options": "Simple", + "fieldname": "previous_work_experience", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Employee External Work History", + "options": "Employee External Work History", + "fieldname": "previous_experience_details", + "fieldtype": "Table", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "History In Company", + "options": "Simple", + "fieldname": "history_in_company", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Employee Internal Work Historys", + "options": "Employee Internal Work History", + "fieldname": "experience_in_company_details", + "fieldtype": "Table", + "permlevel": 0 + }, + { + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Exit", + "fieldname": "exit", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break7", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Resignation Letter Date", + "oldfieldname": "resignation_letter_date", + "fieldname": "resignation_letter_date", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Relieving Date", + "oldfieldname": "relieving_date", + "fieldname": "relieving_date", + "fieldtype": "Date", + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Reason for Leaving", + "oldfieldname": "reason_for_leaving", + "fieldname": "reason_for_leaving", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Leave Encashed?", + "oldfieldname": "leave_encashed", + "options": "\nYes\nNo", + "fieldname": "leave_encashed", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Encashment Date", + "oldfieldname": "encashment_date", + "fieldname": "encashment_date", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "oldfieldtype": "Column Break", + "doctype": "DocField", + "label": "Exit Interview Details", + "oldfieldname": "col_brk6", + "width": "50%", + "fieldname": "exit_interview_details", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Held On", + "oldfieldname": "held_on", + "fieldname": "held_on", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Reason for Resignation", + "oldfieldname": "reason_for_resignation", + "options": "\nBetter Prospects\nHealth Concerns", + "fieldname": "reason_for_resignation", + "fieldtype": "Select", + "permlevel": 0 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "New Workplace", + "oldfieldname": "new_workplace", + "fieldname": "new_workplace", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "oldfieldtype": "Text", + "doctype": "DocField", + "label": "Feedback", + "oldfieldname": "feedback", + "fieldname": "feedback", + "fieldtype": "Small Text", + "permlevel": 0 + }, + { + "print_hide": 1, + "doctype": "DocField", + "label": "File List", + "fieldname": "file_list", + "fieldtype": "Text", + "hidden": 1, + "permlevel": 0 + }, + { + "oldfieldtype": "Small Text", + "doctype": "DocField", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "fieldname": "trash_reason", + "fieldtype": "Small Text", + "permlevel": 1 + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, + "role": "Employee", + "cancel": 0, + "permlevel": 0, + "match": "employee" + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, + "role": "Employee", + "cancel": 0, + "permlevel": 1 + }, + { + "create": 1, + "doctype": "DocPerm", + "write": 1, + "role": "HR User", + "cancel": 1, + "permlevel": 0, + "match": "company" + }, + { + "create": 1, + "doctype": "DocPerm", + "write": 1, + "role": "HR Manager", + "cancel": 1, + "permlevel": 0 + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, + "role": "HR User", + "cancel": 0, + "permlevel": 1 + }, + { + "create": 0, + "doctype": "DocPerm", + "write": 0, + "role": "HR Manager", + "cancel": 0, + "permlevel": 1 + } ] \ No newline at end of file diff --git a/hr/doctype/employee_external_work_history/employee_external_work_history.txt b/hr/doctype/employee_external_work_history/employee_external_work_history.txt index 167675af63..8587320517 100644 --- a/hr/doctype/employee_external_work_history/employee_external_work_history.txt +++ b/hr/doctype/employee_external_work_history/employee_external_work_history.txt @@ -1,120 +1,75 @@ -# DocType, Employee External Work History [ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:35:59', - 'docstatus': 0, - 'modified': '2012-03-27 14:35:59', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'istable': 1, - 'module': u'HR', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'show_in_menu': 0, - 'version': 3 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'name': '__common__', - 'parent': u'Employee External Work History', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Employee External Work History', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'role': u'All', - 'write': 1 - }, - - # DocType, Employee External Work History - { - 'doctype': 'DocType', - 'name': u'Employee External Work History' - }, - - # DocPerm - { - 'doctype': u'DocPerm' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'company_name', - 'fieldtype': u'Data', - 'label': u'Company', - 'oldfieldname': u'company_name', - 'oldfieldtype': u'Data' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'designation', - 'fieldtype': u'Data', - 'label': u'Designation', - 'oldfieldname': u'designation', - 'oldfieldtype': u'Data' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'salary', - 'fieldtype': u'Currency', - 'label': u'Salary', - 'oldfieldname': u'salary', - 'oldfieldtype': u'Currency' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'address', - 'fieldtype': u'Small Text', - 'label': u'Address', - 'oldfieldname': u'address', - 'oldfieldtype': u'Small Text' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'contact', - 'fieldtype': u'Data', - 'label': u'Contact', - 'oldfieldname': u'contact', - 'oldfieldtype': u'Data' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'total_experience', - 'fieldtype': u'Data', - 'label': u'Total Experience', - 'oldfieldname': u'total_experience', - 'oldfieldtype': u'Data' - } + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-07-03 13:29:41", + "modified_by": "Administrator", + "modified": "2012-11-30 11:57:58" + }, + { + "istable": 1, + "name": "__common__", + "doctype": "DocType", + "module": "HR" + }, + { + "name": "__common__", + "parent": "Employee External Work History", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "name": "Employee External Work History", + "doctype": "DocType" + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Company", + "oldfieldname": "company_name", + "fieldname": "company_name", + "fieldtype": "Data" + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Designation", + "oldfieldname": "designation", + "fieldname": "designation", + "fieldtype": "Data" + }, + { + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Salary", + "oldfieldname": "salary", + "fieldname": "salary", + "fieldtype": "Currency" + }, + { + "oldfieldtype": "Small Text", + "doctype": "DocField", + "label": "Address", + "oldfieldname": "address", + "fieldname": "address", + "fieldtype": "Small Text" + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Contact", + "oldfieldname": "contact", + "fieldname": "contact", + "fieldtype": "Data" + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Total Experience", + "oldfieldname": "total_experience", + "fieldname": "total_experience", + "fieldtype": "Data" + } ] \ No newline at end of file diff --git a/patches/november_2012/add_employee_field_in_employee.py b/patches/november_2012/add_employee_field_in_employee.py new file mode 100644 index 0000000000..c8e5b3644f --- /dev/null +++ b/patches/november_2012/add_employee_field_in_employee.py @@ -0,0 +1,6 @@ +import webnotes + +def execute(): + webnotes.clear_perms("Employee") + webnotes.reload_doc("hr", "doctype", "employee") + webnotes.conn.sql("""update tabEmployee set employee=name""") diff --git a/patches/patch_list.py b/patches/patch_list.py index 31289484b2..14921244aa 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -689,4 +689,8 @@ patch_list = [ 'patch_module': 'patches.november_2012', 'patch_file': 'add_theme_to_profile', }, + { + 'patch_module': 'patches.november_2012', + 'patch_file': 'add_employee_field_in_employee', + }, ] \ No newline at end of file From 71d6a0ce1d2f7c1051e6f5ee77e7489480a0f937 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 30 Nov 2012 12:41:46 +0530 Subject: [PATCH 6/6] cleaned up leave application --- home/page/latest_updates/latest_updates.js | 2 + .../leave_application/leave_application.js | 53 +- .../leave_application/leave_application.py | 46 +- .../leave_application/leave_application.txt | 520 ++++++++---------- .../leave_application_list.js | 22 +- .../leave_application_cleanup.py | 9 + patches/patch_list.py | 4 + 7 files changed, 301 insertions(+), 355 deletions(-) create mode 100644 patches/november_2012/leave_application_cleanup.py diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index c47a6fd0d3..24cab01fdf 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,6 +1,8 @@ erpnext.updates = [ ["30th November 2012", [ "Auto Notifications: System will prompt user with pre-set message for auto-notification.", + "Employee: Users with role Employee will only be able to see their Employee Records.", + "Leave Application: Users with role Employee can now apply for leaves. HR User will be able to set Approval or Rejection.", ]], ["29th November 2012", [ "EMail: Form Emails are now via Communication (with Rich Text Etc.).", diff --git a/hr/doctype/leave_application/leave_application.js b/hr/doctype/leave_application/leave_application.js index e8952ca710..00df476ede 100755 --- a/hr/doctype/leave_application/leave_application.js +++ b/hr/doctype/leave_application/leave_application.js @@ -14,39 +14,49 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -// ****************************************** onload ******************************************************** cur_frm.cscript.onload = function(doc, dt, dn) { if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()}); } +cur_frm.cscript.refresh = function(doc, dt, dn) { + cur_frm.set_intro(""); + if(doc.__islocal && !in_list(user_roles, "HR User")) { + cur_frm.set_intro("Fill the form and save it") + } else { + if(in_list(user_roles, "HR User")) { + if(doc.status=="Open") { + cur_frm.set_intro("Please Approve (and Submit) or Reject, or re-assign to applicant for further review."); + } + } else { + if(doc.status=="Open") { + cur_frm.set_intro("Leave application is pending approval."); + } else if(doc.status=="Approved") { + cur_frm.set_intro("Leave application has been approved."); + } else if(doc.status=="Rejected") { + cur_frm.set_intro("Leave application has been rejected."); + } + } + } + + if(doc.status=="Approved" && doc.docstatus!=1) { + cur_frm.savesubmit() + } +} -// ************************************** client triggers *************************************************** -// --------- -// employee -// --------- cur_frm.add_fetch('employee','employee_name','employee_name'); cur_frm.cscript.employee = function (doc, dt, dn){ get_leave_balance(doc, dt, dn); } -// ------------ -// fiscal_year -// ------------ cur_frm.cscript.fiscal_year = function (doc, dt, dn){ get_leave_balance(doc, dt, dn); } -// ----------- -// leave type -// ----------- cur_frm.cscript.leave_type = function (doc, dt, dn){ get_leave_balance(doc, dt, dn); } -// --------- -// half day -// --------- cur_frm.cscript.half_day = function(doc, dt, dn) { if(doc.from_date) { set_multiple(dt,dn,{to_date:doc.from_date}); @@ -54,9 +64,6 @@ cur_frm.cscript.half_day = function(doc, dt, dn) { } } -// --------- -// from date -// --------- cur_frm.cscript.from_date = function(doc, dt, dn) { if(cint(doc.half_day) == 1){ set_multiple(dt,dn,{to_date:doc.from_date}); @@ -64,9 +71,6 @@ cur_frm.cscript.from_date = function(doc, dt, dn) { calculate_total_days(doc, dt, dn); } -// -------- -// to date -// -------- cur_frm.cscript.to_date = function(doc, dt, dn) { if(cint(doc.half_day) == 1 && cstr(doc.from_date) && doc.from_date != doc.to_date){ msgprint("To Date should be same as From Date for Half Day leave"); @@ -75,20 +79,11 @@ cur_frm.cscript.to_date = function(doc, dt, dn) { calculate_total_days(doc, dt, dn); } - -// ******************************************* utilities **************************************************** - -// ------------------ -// get leave balance -// ------------------ get_leave_balance = function(doc, dt, dn) { if(doc.employee && doc.leave_type && doc.fiscal_year) get_server_fields('get_leave_balance', '','', doc, dt, dn, 1); } -// --------------- -// calculate days -// --------------- calculate_total_days = function(doc, dt, dn) { if(doc.from_date && doc.to_date){ if(cint(doc.half_day) == 1) set_multiple(dt,dn,{total_leave_days:0.5}); diff --git a/hr/doctype/leave_application/leave_application.py b/hr/doctype/leave_application/leave_application.py index e71a26a368..2f7e4a8dc0 100755 --- a/hr/doctype/leave_application/leave_application.py +++ b/hr/doctype/leave_application/leave_application.py @@ -38,12 +38,6 @@ class DocType: self.doc = doc self.doclist = doclist - -# ******************************************** client triggers *********************************************** - - # ------------------ - # get leave balance - # ------------------ def get_leave_balance(self): leave_all = sql("select total_leaves_allocated from `tabLeave Allocation` where employee = '%s' and leave_type = '%s' and fiscal_year = '%s' and docstatus = 1" % (self.doc.employee, self.doc.leave_type, self.doc.fiscal_year)) leave_all = leave_all and flt(leave_all[0][0]) or 0 @@ -52,10 +46,6 @@ class DocType: ret = {'leave_balance':leave_all - leave_app} return ret - -# ************************************************ utilities ************************************************* - - # ------------------- def get_holidays(self): """ get total holidays @@ -65,10 +55,6 @@ class DocType: tot_hol = sql("select count(*) from `tabHoliday` h1, `tabHoliday List` h2 where h1.parent = h2.name and h1.holiday_date between '%s' and '%s' and ifnull(h2.is_default,0) = 1 and h2.fiscal_year = %s"% (self.doc.from_date, self.doc.to_date, self.doc.fiscal_year)) return tot_hol and flt(tot_hol[0][0]) or 0 - - # --------------------- - # get total leave days - # --------------------- def get_total_leave_days(self): """ Calculates total leave days based on input and holidays @@ -82,27 +68,15 @@ class DocType: } return ret - -# ************************************************ validate ************************************************* - - # ----------------- - # validate to date - # ----------------- def validate_to_date(self): if self.doc.from_date and self.doc.to_date and (getdate(self.doc.to_date) < getdate(self.doc.from_date)): msgprint("To date cannot be before from date") raise Exception - - # -------------------------------- - # check whether leave type is lwp - # -------------------------------- + def is_lwp(self): lwp = sql("select is_lwp from `tabLeave Type` where name = %s", self.doc.leave_type) return lwp and cint(lwp[0][0]) or 0 - # ------------------------ - # validate balance leaves - # ------------------------ def validate_balance_leaves(self): if self.doc.from_date and self.doc.to_date and not self.is_lwp(): bal = self.get_leave_balance() @@ -111,12 +85,8 @@ class DocType: set(self.doc,'leave_balance',flt(bal['leave_balance'])) set(self.doc,'total_leave_days',flt(tot_leaves['total_leave_days'])) if flt(bal['leave_balance']) < flt(tot_leaves['total_leave_days']): - msgprint("Employee : %s cannot apply for %s of more than %s days" % (self.doc.employee, self.doc.leave_type, flt(bal['leave_balance']))) - raise Exception + msgprint("Warning : There is not enough leave balance") - # - # validate overlapping leaves - # def validate_leave_overlap(self): for d in sql("""select name, leave_type, posting_date, from_date, to_date from `tabLeave Application` @@ -128,9 +98,6 @@ class DocType: msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : %s" % (self.doc.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name']), raise_exception = 1) - # --------------------------------------------------------------------- - # validate max days for which leave can be applied for particular type - # --------------------------------------------------------------------- def validate_max_days(self): max_days = sql("select max_days_allowed from `tabLeave Type` where name = '%s'" %(self.doc.leave_type)) max_days = max_days and flt(max_days[0][0]) or 0 @@ -138,12 +105,13 @@ class DocType: msgprint("Sorry ! You cannot apply for %s for more than %s days" % (self.doc.leave_type, max_days)) raise Exception - - # --------- - # validate - # --------- def validate(self): self.validate_to_date() self.validate_balance_leaves() self.validate_leave_overlap() self.validate_max_days() + + def on_submit(self): + if self.doc.status != "Approved": + webnotes.msgprint("""Only Approved Leave Applications can be Submitted.""", + raise_exception=True) diff --git a/hr/doctype/leave_application/leave_application.txt b/hr/doctype/leave_application/leave_application.txt index c87c746b2f..6a33df61bc 100644 --- a/hr/doctype/leave_application/leave_application.txt +++ b/hr/doctype/leave_application/leave_application.txt @@ -1,285 +1,239 @@ -# DocType, Leave Application [ - - # These values are common in all dictionaries - { - u'creation': '2012-05-15 12:14:45', - u'docstatus': 0, - u'modified': '2012-10-02 11:19:44', - u'modified_by': u'Administrator', - u'owner': u'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': u'1310019491', - 'autoname': u'LAP/.#####', - 'colour': u'White:FFF', - u'doctype': u'DocType', - 'document_type': u'Transaction', - 'is_submittable': 1, - 'module': u'HR', - u'name': u'__common__', - 'search_fields': u'employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year', - 'section_style': u'Simple', - 'show_in_menu': 0, - 'subject': u'From %(employee_name)s, %(designation)s', - 'tag_fields': u'leave_type', - 'version': 1 - }, - - # These values are common for all DocField - { - u'doctype': u'DocField', - u'name': u'__common__', - 'parent': u'Leave Application', - 'parentfield': u'fields', - 'parenttype': u'DocType' - }, - - # These values are common for all DocPerm - { - u'doctype': u'DocPerm', - u'name': u'__common__', - 'parent': u'Leave Application', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'read': 1 - }, - - # DocType, Leave Application - { - u'doctype': u'DocType', - u'name': u'Leave Application' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break0', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'employee', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Employee', - 'options': u'Employee', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'employee_name', - 'fieldtype': u'Data', - 'in_filter': 1, - 'label': u'Employee Name', - 'permlevel': 1, - 'search_index': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'leave_type', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Leave Type', - 'options': u'link:Leave Type', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'leave_balance', - 'fieldtype': u'Currency', - 'label': u'Leave Balance', - 'permlevel': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'Today', - u'doctype': u'DocField', - 'fieldname': u'posting_date', - 'fieldtype': u'Date', - 'label': u'Posting Date', - 'no_copy': 1, - 'permlevel': 1, - 'reqd': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'fiscal_year', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Fiscal Year', - 'options': u'link:Fiscal Year', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break1', - 'fieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'half_day', - 'fieldtype': u'Check', - 'label': u'Half Day', - 'permlevel': 0, - 'trigger': u'Client' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'from_date', - 'fieldtype': u'Date', - 'label': u'From Date', - 'permlevel': 0, - 'search_index': 1, - 'trigger': u'Client' - }, - - # DocField - { - 'colour': u'White:FFF', - u'doctype': u'DocField', - 'fieldname': u'to_date', - 'fieldtype': u'Date', - 'label': u'To Date', - 'permlevel': 0, - 'search_index': 1, - 'trigger': u'Client' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'total_leave_days', - 'fieldtype': u'Currency', - 'label': u'Total Leave Days', - 'permlevel': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'description', - 'fieldtype': u'Small Text', - 'label': u'Description', - 'permlevel': 0, - 'width': u'300px' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'letter_head', - 'fieldtype': u'Link', - 'label': u'Letter Head', - 'options': u'Letter Head', - 'permlevel': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'amended_from', - 'fieldtype': u'Data', - 'label': u'Amended From', - 'permlevel': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'amendment_date', - 'fieldtype': u'Date', - 'label': u'Amendment Date', - 'permlevel': 1 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - u'doctype': u'DocPerm', - 'match': u'owner', - 'permlevel': 0, - 'role': u'Employee', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR User', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - 'amend': 1, - 'cancel': 1, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'HR Manager', - 'submit': 1, - 'write': 1 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR User' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'HR Manager' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Employee' - } + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-11-02 17:16:54", + "modified_by": "Administrator", + "modified": "2012-11-30 12:17:27" + }, + { + "is_submittable": 1, + "autoname": "LAP/.#####", + "name": "__common__", + "search_fields": "employee,employee_name,leave_type,from_date,to_date,total_leave_days,fiscal_year", + "module": "HR", + "doctype": "DocType", + "document_type": "Transaction" + }, + { + "name": "__common__", + "parent": "Leave Application", + "doctype": "DocField", + "parenttype": "DocType", + "parentfield": "fields" + }, + { + "name": "__common__", + "parent": "Leave Application", + "read": 1, + "doctype": "DocPerm", + "parenttype": "DocType", + "parentfield": "permissions" + }, + { + "name": "Leave Application", + "doctype": "DocType" + }, + { + "default": "Open", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Status", + "options": "Open\nApproved\nRejected", + "fieldname": "status", + "fieldtype": "Select", + "permlevel": 3 + }, + { + "search_index": 1, + "doctype": "DocField", + "label": "Leave Type", + "options": "link:Leave Type", + "fieldname": "leave_type", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "search_index": 1, + "colour": "White:FFF", + "doctype": "DocField", + "label": "From Date", + "trigger": "Client", + "fieldname": "from_date", + "fieldtype": "Date", + "reqd": 1, + "permlevel": 0 + }, + { + "search_index": 1, + "colour": "White:FFF", + "doctype": "DocField", + "label": "To Date", + "trigger": "Client", + "fieldname": "to_date", + "fieldtype": "Date", + "reqd": 1, + "permlevel": 0 + }, + { + "colour": "White:FFF", + "doctype": "DocField", + "label": "Half Day", + "trigger": "Client", + "fieldname": "half_day", + "fieldtype": "Check", + "permlevel": 0 + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break1", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Leave Balance", + "fieldname": "leave_balance", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "doctype": "DocField", + "label": "Total Leave Days", + "fieldname": "total_leave_days", + "fieldtype": "Currency", + "permlevel": 1 + }, + { + "search_index": 1, + "doctype": "DocField", + "label": "Employee", + "options": "Employee", + "fieldname": "employee", + "fieldtype": "Link", + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "search_index": 0, + "doctype": "DocField", + "label": "Employee Name", + "fieldname": "employee_name", + "fieldtype": "Data", + "permlevel": 1, + "in_filter": 1 + }, + { + "doctype": "DocField", + "fieldname": "sb10", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "Reason", + "width": "300px", + "fieldname": "description", + "fieldtype": "Text Editor", + "permlevel": 0 + }, + { + "doctype": "DocField", + "label": "HR Details", + "fieldname": "sb12", + "fieldtype": "Section Break", + "permlevel": 2 + }, + { + "default": "Today", + "colour": "White:FFF", + "doctype": "DocField", + "label": "Posting Date", + "no_copy": 1, + "fieldname": "posting_date", + "fieldtype": "Date", + "reqd": 1, + "permlevel": 2 + }, + { + "search_index": 0, + "doctype": "DocField", + "label": "Fiscal Year", + "options": "link:Fiscal Year", + "fieldname": "fiscal_year", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 2, + "in_filter": 1 + }, + { + "doctype": "DocField", + "label": "Letter Head", + "options": "Letter Head", + "fieldname": "letter_head", + "fieldtype": "Link", + "permlevel": 2 + }, + { + "doctype": "DocField", + "label": "Amended From", + "fieldname": "amended_from", + "fieldtype": "Data", + "permlevel": 2 + }, + { + "doctype": "DocField", + "label": "Amendment Date", + "fieldname": "amendment_date", + "fieldtype": "Date", + "permlevel": 2 + }, + { + "create": 1, + "doctype": "DocPerm", + "write": 1, + "role": "Employee", + "permlevel": 0, + "match": "employee" + }, + { + "doctype": "DocPerm", + "role": "All", + "permlevel": 1 + }, + { + "amend": 1, + "create": 1, + "doctype": "DocPerm", + "submit": 1, + "write": 1, + "role": "HR User", + "cancel": 1, + "permlevel": 0 + }, + { + "amend": 0, + "create": 0, + "doctype": "DocPerm", + "submit": 0, + "write": 1, + "role": "HR User", + "cancel": 0, + "permlevel": 2 + }, + { + "doctype": "DocPerm", + "role": "All", + "permlevel": 3 + }, + { + "doctype": "DocPerm", + "write": 1, + "role": "HR User", + "permlevel": 3 + } ] \ No newline at end of file diff --git a/hr/doctype/leave_application/leave_application_list.js b/hr/doctype/leave_application/leave_application_list.js index 4bcbab83c2..4c80e7fefe 100644 --- a/hr/doctype/leave_application/leave_application_list.js +++ b/hr/doctype/leave_application/leave_application_list.js @@ -3,6 +3,7 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({ init: function(d) { this._super(d) this.fields = this.fields.concat([ + "`tabLeave Application`.status", "`tabLeave Application`.employee_name", "`tabLeave Application`.total_leave_days", "`tabLeave Application`.from_date", @@ -12,8 +13,21 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({ this.stats = this.stats.concat(['company']); }, + label_style: { + "status": { + "Open": "danger", + "Approved": "success", + "Rejected": "info", + } + }, + prepare_data: function(data) { this._super(data); + + data.label_style = this.label_style.status[data.status]; + data.status_html = repl('%(status)s', data); + data.from_date = wn.datetime.str_to_user(data.from_date); data.to_date = wn.datetime.str_to_user(data.to_date); data.date_range = (data.from_date === data.to_date) @@ -28,10 +42,10 @@ wn.doclistviews['Leave Application'] = wn.views.ListView.extend({ {width: '3%', content: 'check'}, {width: '5%', content:'avatar'}, {width: '3%', content:'docstatus'}, + {width: '15%', content:'status_html'}, {width: '12%', content:'name'}, - {width: '37%', content:'employee_name+tags'}, - {width: '10%', content:'total_leave_days', - css: {'color':'#777'}}, - {width: '30%', content:'date_range'}, + {width: '25%', content:'employee_name+tags'}, + {width: '25%', content:'date_range'}, + {width: '12%', content:'modified'}, ] }); \ No newline at end of file diff --git a/patches/november_2012/leave_application_cleanup.py b/patches/november_2012/leave_application_cleanup.py new file mode 100644 index 0000000000..18e69cfa8d --- /dev/null +++ b/patches/november_2012/leave_application_cleanup.py @@ -0,0 +1,9 @@ +import webnotes + +def execute(): + webnotes.clear_perms("Leave Application") + webnotes.reload_doc("hr", "doctype", "leave_application") + webnotes.conn.sql("""update `tabLeave Application` set status='Approved' + where docstatus=1""") + webnotes.conn.sql("""update `tabLeave Application` set status='Open' + where docstatus=0""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 14921244aa..100f25b98f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -693,4 +693,8 @@ patch_list = [ 'patch_module': 'patches.november_2012', 'patch_file': 'add_employee_field_in_employee', }, + { + 'patch_module': 'patches.november_2012', + 'patch_file': 'leave_application_cleanup', + }, ] \ No newline at end of file
\ -

%(sender)s on %(when)s \ - \ - Show Details

\ - \ -