mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-18 00:55:02 +00:00
separated communication view
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
// Module CRM
|
||||
|
||||
wn.require("public/app/js/communication.js");
|
||||
|
||||
wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
||||
wn.require('app/support/doctype/communication/communication.js');
|
||||
|
||||
@@ -41,8 +43,6 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(user=='Guest') doc.naming_series = 'WebLead';
|
||||
|
||||
cur_frm.add_fetch('customer', 'customer_name', 'company_name');
|
||||
|
||||
cur_frm.cscript.make_communication_body();
|
||||
|
||||
if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) {
|
||||
cur_frm.fields_dict.lead_owner.get_query = erpnext.utils.profile_query;
|
||||
@@ -67,32 +67,22 @@ cur_frm.cscript.refresh_custom_buttons = function(doc) {
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
// custom buttons
|
||||
//---------------
|
||||
cur_frm.cscript.refresh_custom_buttons(doc);
|
||||
|
||||
erpnext.hide_naming_series();
|
||||
|
||||
if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn);
|
||||
|
||||
new erpnext.CommunicationView({
|
||||
list: wn.model.get("Communication", {"lead": doc.name}),
|
||||
parent: cur_frm.fields_dict.communication_html.wrapper
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Client Side Triggers
|
||||
// ===========================================================
|
||||
// ************ Status ******************
|
||||
|
||||
cur_frm.cscript.status = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.refresh(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
//Trigger in Item Table
|
||||
//===================================
|
||||
cur_frm.cscript.item_code=function(doc,cdt,cdn){
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) { get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}
|
||||
}
|
||||
|
||||
// Create New Customer
|
||||
// ===============================================================
|
||||
cur_frm.cscript['Create Customer'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||
|
||||
@@ -18,48 +18,28 @@
|
||||
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, flt, validate_email_add
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes import session, 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
|
||||
|
||||
#check status of lead
|
||||
#------------------------
|
||||
|
||||
def onload(self):
|
||||
self.add_communication_list()
|
||||
|
||||
def check_status(self):
|
||||
chk = sql("select status from `tabLead` where name=%s", self.doc.name)
|
||||
chk = chk and chk[0][0] or ''
|
||||
return cstr(chk)
|
||||
|
||||
|
||||
# Get item detail (will be removed later)
|
||||
#=======================================
|
||||
def get_item_detail(self,item_code):
|
||||
it=sql("select item_name,brand,item_group,description,stock_uom from `tabItem` where name='%s'"%item_code)
|
||||
if it:
|
||||
ret = {
|
||||
'item_name' : it and it[0][0] or '',
|
||||
'brand' : it and it[0][1] or '',
|
||||
'item_group' : it and it[0][2] or '',
|
||||
'description': it and it[0][3] or '',
|
||||
'uom' : it and it[0][4] or ''
|
||||
}
|
||||
return ret
|
||||
|
||||
def validate(self):
|
||||
if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason:
|
||||
@@ -79,20 +59,6 @@ class DocType:
|
||||
if self.doc.contact_date:
|
||||
self.add_calendar_event()
|
||||
|
||||
if not self.doc.naming_series:
|
||||
if session['user'] == 'Guest':
|
||||
import webnotes.model.doctype
|
||||
docfield = webnotes.model.doctype.get('Lead')
|
||||
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
||||
if series:
|
||||
sr = series[0].split("\n")
|
||||
set(self.doc, 'naming_series', sr[0])
|
||||
else:
|
||||
msgprint("Please specify naming series")
|
||||
raise Exception
|
||||
|
||||
# Add to Calendar
|
||||
# ===========================================================================
|
||||
def add_calendar_event(self):
|
||||
# delete any earlier event by this lead
|
||||
sql("delete from tabEvent where ref_type='Lead' and ref_name=%s", self.doc.name)
|
||||
@@ -113,3 +79,9 @@ class DocType:
|
||||
event_user = addchild(ev, 'event_individuals', 'Event User')
|
||||
event_user.person = self.doc.contact_by
|
||||
event_user.save()
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""update tabCommunication set lead='' where lead=%s""",
|
||||
self.doc.name)
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""",
|
||||
self.doc.name)
|
||||
@@ -4,7 +4,7 @@
|
||||
"docstatus": 0,
|
||||
"creation": "2012-11-02 17:16:46",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-11-26 11:12:27"
|
||||
"modified": "2012-11-26 18:13:22"
|
||||
},
|
||||
{
|
||||
"autoname": "naming_series:",
|
||||
@@ -200,7 +200,6 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Communication History",
|
||||
"fieldname": "communication_history",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
|
||||
Reference in New Issue
Block a user