From d7fe2bfe1b2158ecdb91ec4df200af23e5600c89 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 29 Nov 2012 11:49:56 +0530 Subject: [PATCH] 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 41d0a9f4741..3a50f9d70c3 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 4d46f2cef0c..00000000000 --- 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 771b4095952..00000000000 --- 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 26cee77910f..66339db1223 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 28bfca1ff65..e44e6737012 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 0bf4d3c05e9..31289484b23 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 70a08affecd..00000000000 --- 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 39522f86cca..081a57a0fd6 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 689b40990b8..c40e932f315 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 32efe037858..d7a80a828b0 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 baffc488252..00000000000 --- 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 04e6c804dee..00000000000 --- 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 f365fe38b41..00000000000 --- 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 1f01c50c38d..00000000000 --- 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 8c8d98c8b43..00000000000 --- 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 519d34391d7..2d89c6e3868 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 d51c0f5887b..3876ca20aef 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 bbf5bf855ea..3b1b3c983da 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
\ -

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

\ - \ -