new doctype: communication

This commit is contained in:
Anand Doshi 2012-05-31 14:53:55 +05:30
parent 6971f577da
commit a6708fb748
20 changed files with 1073 additions and 334 deletions

View File

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
cur_frm.cscript.onload = function(doc,dt,dn){
@ -28,6 +29,7 @@ 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) {
@ -44,7 +46,8 @@ 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.make_history(doc,dt,dn);
cur_frm.cscript.render_communication_list(doc, cdt, cdn);
cur_frm.cscript.make_history(doc,dt,dn);
}
}
@ -109,44 +112,88 @@ cur_frm.cscript.make_contact = function() {
// Transaction History
cur_frm.cscript.make_po_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Order',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'status', width: '25%', label: 'Status', type: 'Data'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Order`.status",
"`tabPurchase Order`.currency",
"ifnull(`tabPurchase Order`.grand_total_import, 0) as grand_total_import",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '20%', content: 'name'},
{width: '30%', content: 'status',
css: {'text-align': 'right', 'color': '#777'}},
{width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Order', parent, ListView);
}
cur_frm.cscript.make_pr_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Receipt',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'status', width: '15%', label: 'Status', type: 'Data'},
{fieldname: 'per_billed', width: '10%', label: '% Billed',
type: 'Percentage', style: 'text-align: right'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Receipt`.status",
"`tabPurchase Receipt`.currency",
"ifnull(`tabPurchase Receipt`.grand_total_import, 0) as grand_total_import",
"ifnull(`tabPurchase Receipt`.per_billed, 0) as per_billed",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '20%', content: 'name'},
{width: '20%', content: 'status',
css: {'text-align': 'right', 'color': '#777'}},
{width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '10%', content: 'per_billed', type: 'bar-graph', label: 'Billed'},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Receipt', parent, ListView);
}
cur_frm.cscript.make_pi_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Invoice',
[
{fieldname: 'name', width: '30%', label: 'Id', type: 'Link'},
{fieldname: 'modified', width: '35%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tabPurchase Invoice`.currency",
"ifnull(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '30%', content: 'name'},
{width: '55%', content: 'grand_total_import', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Purchase Invoice', parent, ListView);
}

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:52',
'creation': '2012-05-15 12:14:41',
'docstatus': 0,
'modified': '2012-03-27 14:35:52',
'modified': '2012-05-31 13:18:29',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -25,7 +25,7 @@
'show_in_menu': 0,
'subject': u' ',
'tag_fields': u'supplier_type',
'version': 87
'version': 1
},
# These values are common for all DocField
@ -53,6 +53,30 @@
'name': u'Supplier'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'doctype': u'DocPerm',
@ -72,30 +96,6 @@
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'submit': 0,
'write': 0
},
# DocField
{
'colour': u'White:FFF',
@ -218,6 +218,24 @@
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_history',
'fieldtype': u'Section Break',
'label': u'Communication History',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',

View File

@ -0,0 +1,97 @@
def execute():
import webnotes
import webnotes.model.sync
webnotes.model.sync.sync('support', 'communication')
webnotes.conn.commit()
webnotes.conn.begin()
# change doctype property setter and custom fields, and save them
move_customizations()
try:
remove_communication_log()
except Exception, e:
if e.args[0] != 1146:
raise e
def move_customizations():
import webnotes.model.doc
import webnotes.model.doctype
res = webnotes.conn.sql("""\
delete from `tabProperty Setter`
where property='previous_field'
and doc_type = 'Communication Log'""")
res = webnotes.conn.sql("""\
select name from `tabCustom Field`
where dt='Communication Log'""")
for r in res:
d = webnotes.model.doc.Document('Custom Field', r[0])
d.dt = 'Communication'
d.validate()
d.save()
d.on_update()
res = webnotes.conn.sql("""\
select field_name from `tabProperty Setter`
where doc_type='Communication Log' and field_name is not null""")
doclist = webnotes.model.doctype.get('Communication', 0)
field_list = [d.fieldname for d in doclist if d.doctype=='DocField']
for r in res:
if r[0] in field_list:
webnotes.conn.sql("""\
update `tabProperty Setter`
set doc_type = 'Communication'
where field_name=%s and doc_type='Communication Log'""", r[0])
webnotes.conn.sql("""\
delete from `tabProperty Setter`
where doc_type='Communication Log'""")
def remove_communication_log():
import webnotes
import webnotes.model
import webnotes.model.doc
# get all communication log records
comm_log_list = webnotes.conn.sql("select * from `tabCommunication Log`",
as_dict=1)
# copy it to communication
for comm_log in comm_log_list:
d = webnotes.model.doc.Document('Communication')
for key in comm_log.keys():
if key not in webnotes.model.default_fields:
d.fields[key] = comm_log[key]
parenttype = (comm_log.get('parenttype') or '').lower()
if parenttype in d.fields.keys():
d.fields[parenttype] = comm_log.get('parent')
d.subject = 'Follow Up'
d.content = comm_log.get('notes') or ''
d.medium = comm_log.get('follow_up_type') or ''
d.sales_person = comm_log.get('follow_up_by')
d.communication_date = comm_log.get('date')
d.category = 'Miscellaneous'
d.action = 'No Action'
d.save()
# delete records with parent type "Customer", "Lead", "Supplier"
webnotes.conn.sql("""\
delete from `tabCommunication Log`
where parenttype in ('Customer', 'Lead', 'Supplier',
'Opportunity', 'Quotation')""")
# if all records deleted, drop table communication log
# and delete doctype communication log
# if for some reason, records remain, dont drop table and dont delete doctype
count = webnotes.conn.sql("select count(*) from `tabCommunication Log`")[0][0]
if not count:
webnotes.model.delete_doc('DocType', 'Communication Log')
webnotes.conn.commit()
webnotes.conn.sql("drop table `tabCommunication Log`")
webnotes.conn.begin()

View File

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('erpnext/setup/doctype/contact_control/contact_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
/* ********************************* onload ********************************************* */
@ -31,6 +32,8 @@ 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) {
@ -62,6 +65,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
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);
}
}
@ -150,61 +154,83 @@ cur_frm.fields_dict['lead_name'].get_query = function(doc,dt,dn){
// Transaction History
// functions called by these functions are defined in contact_control.js
// functions called by these functions are defined in communication.js
cur_frm.cscript.make_qtn_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Quotation',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'status', width: '25%', label: 'Status', type: 'Data'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
cur_frm.cscript.get_common_list_view(parent, doc, 'Quotation');
}
cur_frm.cscript.make_so_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Sales Order',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'status', width: '25%', label: 'Status', type: 'Data'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
cur_frm.cscript.get_common_list_view(parent, doc, 'Sales Order');
}
cur_frm.cscript.make_dn_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Delivery Note',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'status', width: '25%', label: 'Status', type: 'Data'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
cur_frm.cscript.get_common_list_view(parent, doc, 'Delivery Note');
}
cur_frm.cscript.get_common_list_view = function(parent, doc, doctype) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"`tab" + doctype + "`.status",
"`tab" + doctype + "`.currency",
"ifnull(`tab" + doctype + "`.grand_total_export, 0) as grand_total_export",
]);
},
prepare_data: function(data) {
this._super(data);
data.grand_total_export = data.currency + " " + fmt_money(data.grand_total_export)
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '25%', content: 'name'},
{width: '25%', content: 'status'},
{width: '35%', content: 'grand_total_export', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, doctype, parent, ListView);
}
cur_frm.cscript.make_si_list = function(parent, doc) {
cur_frm.cscript.render_transaction_history(parent, doc, 'Sales Invoice',
[
{fieldname: 'name', width: '28%', label: 'Id', type: 'Link'},
{fieldname: 'outstanding_amount', width: '25%',
label: 'Outstanding Amount',
type: 'Currency', style: 'text-align: right; color: #777'},
{fieldname: 'modified', width: '12%', label: 'Last Modified On',
type: 'Date', style: 'text-align: right; color: #777'},
{fieldname: 'currency', width: '0%', label: 'Currency',
style: 'display: hidden'},
{fieldname: 'grand_total', width: '35%', label: 'Grand Total',
type: 'Currency', style: 'text-align: right'},
]);
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
this._super(doclistview);
this.fields = this.fields.concat([
"ifnull(`tabSales Invoice`.outstanding_amount, 0) as outstanding_amount",
"`tabSales Invoice`.currency",
"ifnull(`tabSales Invoice`.conversion_rate, 0) as conversion_rate",
"ifnull(`tabSales Invoice`.grand_total_export, 0) as grand_total_export",
]);
},
prepare_data: function(data) {
this._super(data);
if (data.outstanding_amount) {
data.outstanding_amount = data.currency + " " +
fmt_money(flt(data.outstanding_amount)/flt(data.conversion_rate)) +
" [outstanding]";
} else {
data.outstanding_amount = '';
}
data.grand_total_export = data.currency + " " + fmt_money(data.grand_total_export);
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '25%', content: 'name'},
{width: '25%', content: 'outstanding_amount',
css: {'text-align': 'right', 'color': '#777'}},
{width: '35%', content: 'grand_total_export', css: {'text-align': 'right'}},
{width: '12%', content:'modified', css: {'text-align': 'right'}}
],
});
cur_frm.cscript.render_list(doc, 'Sales Invoice', parent, ListView);
}

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-04-13 11:56:26',
'creation': '2012-05-15 12:14:51',
'docstatus': 0,
'modified': '2012-04-19 17:12:24',
'modified': '2012-05-31 11:41:06',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -303,6 +303,24 @@
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_history',
'fieldtype': u'Section Break',
'label': u'Communication History',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',

View File

@ -8,19 +8,20 @@
//
// 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
// 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 <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Module CRM
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(user =='Guest'){
hide_field(['status', 'naming_series', 'order_lost_reason',
if(user =='Guest'){
hide_field(['status', 'naming_series', 'order_lost_reason',
'customer', 'rating', 'fax', 'website', 'territory',
'TerritoryHelp', 'address_line1', 'address_line2', 'city', 'state',
'country', 'pincode', 'address', 'lead_owner', 'market_segment',
@ -29,29 +30,33 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
'contact_date_ref', 'to_discuss', 'more_info', 'follow_up',
'communication_history', 'cc_to', 'subject', 'message', 'lead_attachment_detail',
'Create Customer', 'Create Opportunity', 'transaction_date', 'type', 'source']);
doc.source = 'Website';
}
if(!doc.status) set_multiple(dt,dn,{status:'Open'});
doc.source = 'Website';
}
if(!doc.status) set_multiple(dt,dn,{status:'Open'});
if (!doc.date){
doc.date = date.obj_to_str(new Date());
}
// set naming series
if(user=='Guest') doc.naming_series = 'WebLead';
cur_frm.add_fetch('customer', 'customer_name', 'company_name');
if (!doc.date){
doc.date = date.obj_to_str(new Date());
}
// set naming series
if(user=='Guest') doc.naming_series = 'WebLead';
cur_frm.add_fetch('customer', 'customer_name', 'company_name');
cur_frm.cscript.make_communication_body();
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// custom buttons
//---------------
cur_frm.clear_custom_buttons()
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
// custom buttons
//---------------
cur_frm.clear_custom_buttons()
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
if (doc.source != 'Existing Customer') cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']);
cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
erpnext.hide_naming_series();
cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
erpnext.hide_naming_series();
if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn);
}
@ -59,90 +64,90 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// ===========================================================
// ************ Status ******************
cur_frm.cscript.status = function(doc, cdt, cdn){
cur_frm.cscript.refresh(doc, cdt, cdn);
cur_frm.cscript.refresh(doc, cdt, cdn);
}
cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
loadpage('Sales Browser',call_back);
loadpage('Sales Browser',call_back);
}
//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);}
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([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is already converted to customer");
}
else{
n = createLocal("Customer");
$c('dt_map', args={
'docs':compress_doclist([locals["Customer"][n]]),
'from_doctype':'Lead',
'to_doctype':'Customer',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Customer']]"
},
function(r,rt) {
loaddoc("Customer", n);
}
);
}
}
);
var doc = cur_frm.doc;
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is already converted to customer");
}
else{
n = createLocal("Customer");
$c('dt_map', args={
'docs':compress_doclist([locals["Customer"][n]]),
'from_doctype':'Lead',
'to_doctype':'Customer',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Customer']]"
},
function(r,rt) {
loaddoc("Customer", n);
}
);
}
}
);
}
// send email
// ===============================================================
cur_frm.cscript.send_email = function(doc,cdt,cdn){
if(doc.__islocal != 1){
$c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){});
}else{
msgprint("Please save lead first before sending email")
}
if(doc.__islocal != 1){
$c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){});
}else{
msgprint("Please save lead first before sending email")
}
}
// Create New Opportunity
// ===============================================================
cur_frm.cscript['Create Opportunity'] = function(){
var doc = cur_frm.doc;
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
}
else{
n = createLocal("Opportunity");
$c('dt_map', args={
'docs':compress_doclist([locals["Opportunity"][n]]),
'from_doctype':'Lead',
'to_doctype':'Opportunity',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Opportunity']]"
}
, function(r,rt) {
loaddoc("Opportunity", n);
}
);
}
}
);
var doc = cur_frm.doc;
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
}
else{
n = createLocal("Opportunity");
$c('dt_map', args={
'docs':compress_doclist([locals["Opportunity"][n]]),
'from_doctype':'Lead',
'to_doctype':'Opportunity',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Opportunity']]"
}
, function(r,rt) {
loaddoc("Opportunity", n);
}
);
}
}
);
}
//get query select Territory
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-04-02 16:02:08',
'creation': '2012-05-15 12:14:52',
'docstatus': 0,
'modified': '2012-04-30 15:20:50',
'modified': '2012-05-30 12:43:03',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -314,13 +314,13 @@
# DocField
{
'allow_on_submit': 0,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'follow_up',
'fieldtype': u'Table',
'label': u'Communication Log',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'oldfieldname': u'follow_up',
'oldfieldtype': u'Table',
'options': u'Communication Log',
'permlevel': 0
},

View File

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
cur_frm.cscript.refresh = function(doc, cdt, cdn){
erpnext.hide_naming_series();
@ -25,7 +26,7 @@ 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
@ -49,6 +50,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
// setup fetch
cur_frm.cscript.set_fetch();
cur_frm.cscript.make_communication_body();
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-04-02 16:02:08',
'creation': '2012-05-15 12:14:52',
'docstatus': 0,
'modified': '2012-04-30 15:34:34',
'modified': '2012-05-31 12:42:38',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -282,12 +282,11 @@
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'follow_up',
'fieldtype': u'Table',
'label': u'Communication Log',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'oldfieldname': u'follow_up',
'oldfieldtype': u'Table',
'options': u'Communication Log',
'permlevel': 0
},

View File

@ -25,6 +25,7 @@ wn.require('erpnext/selling/doctype/sales_common/sales_common.js');
wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('erpnext/utilities/doctype/sms_control/sms_control.js');
wn.require('erpnext/setup/doctype/notification_control/notification_control.js');
wn.require('erpnext/support/doctype/communication/communication.js');
// ONLOAD
// ===================================================================================
@ -39,7 +40,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
if(doc.quotation_to) {
if(doc.quotation_to == 'Customer') {
hide_field(['lead', 'lead_name']);
@ -48,9 +49,11 @@ 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.onload_post_render = function(doc, dt, dn) {
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, dt, dn);
@ -95,6 +98,8 @@ 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);
}

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-04-30 18:40:10',
'creation': '2012-05-21 11:43:59',
'docstatus': 0,
'modified': '2012-04-30 20:30:45',
'modified': '2012-05-31 11:43:18',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -51,8 +51,7 @@
'name': '__common__',
'parent': u'Quotation',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
'parenttype': u'DocType'
},
# DocType, Quotation
@ -61,6 +60,13 @@
'name': u'Quotation'
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'user print'
},
# DocPerm
{
'amend': 0,
@ -68,6 +74,7 @@
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'read': 1,
'role': u'Sales Manager',
'submit': 0,
'write': 0
@ -80,6 +87,7 @@
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'read': 1,
'role': u'Sales Manager',
'submit': 1,
'write': 1
@ -92,6 +100,7 @@
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'read': 1,
'role': u'Sales User',
'submit': 1,
'write': 1
@ -104,6 +113,7 @@
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'read': 1,
'role': u'Sales User',
'submit': 0,
'write': 0
@ -114,6 +124,7 @@
'doctype': u'DocPerm',
'match': u'customer_name',
'permlevel': 0,
'read': 1,
'role': u'Customer'
},
@ -124,6 +135,7 @@
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'read': 1,
'role': u'Maintenance Manager',
'submit': 1,
'write': 1
@ -133,6 +145,7 @@
{
'doctype': u'DocPerm',
'permlevel': 1,
'read': 1,
'role': u'Maintenance Manager'
},
@ -143,6 +156,7 @@
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'read': 1,
'role': u'Maintenance User',
'submit': 1,
'write': 1
@ -152,6 +166,7 @@
{
'doctype': u'DocPerm',
'permlevel': 1,
'read': 1,
'role': u'Maintenance User'
},
@ -1240,12 +1255,11 @@
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'follow_up',
'fieldtype': u'Table',
'label': u'Communication Log',
'fieldname': u'communication_html',
'fieldtype': u'HTML',
'label': u'Communication HTML',
'oldfieldname': u'follow_up',
'oldfieldtype': u'Table',
'options': u'Communication Log',
'permlevel': 0,
'print_hide': 1,
'width': u'40px'

View File

@ -9,7 +9,6 @@ cur_frm.cscript.make_hl_body = function(){
cur_frm.history_html = $a(cur_frm.fields_dict['history_html'].wrapper,'div');
}
// make history
// -------------
cur_frm.cscript.make_history = function(doc,dt,dn){
@ -50,42 +49,6 @@ cur_frm.cscript.make_history_list = function(parent,doc){
}
}
// run list
// ---------
cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){
parent.innerHTML = '';
$dh(parent);
lst.doc = doc;
lst.dn = dn;
lst.nm = nm;
lst.page_len = 10;
lst.get_query = function(){
this.query = q;
this.query_max = q_max;
}
lst.make(parent);
lst.run();
lst.onrun = function(){
$ds(parent);
if(!this.has_data()){
parent.innerHTML = '';
var dv = $a(parent,'div','help_box');
$a(dv,'span').innerHTML = "No " + this.dn + " found. ";
var lbl = 'Create the <b>first</b> ' + this.dn + ' for ' + this.doc.name;
var sp = $a(dv,'span');
sp.nm = this.nm;
$(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); });
}
}
}
// get sates on country trigger
// -----------------------------
cur_frm.cscript.get_states=function(doc,dt,dn){
@ -120,81 +83,4 @@ if(cur_frm.fields_dict['territory']){
cur_frm.fields_dict['territory'].get_query = function(doc,dt,dn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}
}
// Transaction History related functions
cur_frm.cscript.render_transaction_history = function(parent, doc, doctype, args) {
$(parent).css({ 'padding-top': '10px' });
cur_frm.transaction_list = new wn.ui.Listing({
parent: parent,
page_length: 10,
get_query: function() {
return cur_frm.cscript.get_query_transaction_history({
parent: doc.doctype.toLowerCase(),
parent_name: doc.name,
doctype: doctype,
fields: (function() {
var fields = [];
for(var i in args) {
fields.push(args[i].fieldname);
}
return fields.join(", ");
})(),
});
},
as_dict: 1,
no_result_message: repl('No %(doctype)s created for this %(parent)s',
{ doctype: doctype, parent: doc.doctype }),
render_row: function(wrapper, data) {
render_html = cur_frm.cscript.render_transaction_history_row(data, args, doctype);
$(wrapper).html(render_html);
},
});
cur_frm.transaction_list.run();
}
cur_frm.cscript.render_transaction_history_row = function(data, args, doctype) {
var content = [];
var currency = data.currency;
for (var a in args) {
for (var d in data) {
if (args[a].fieldname === d && args[a].fieldname !== 'currency') {
if (args[a].type === 'Link') {
data[d] = repl('<a href="#!Form/%(doctype)s/%(name)s">\
%(name)s</a>', { doctype: doctype, name: data[d]});
} else if (args[a].type === 'Currency') {
data[d] = currency + " " + fmt_money(data[d]);
} else if (args[a].type === 'Percentage') {
data[d] = flt(data[d]) + '%';
} else if (args[a].type === 'Date') {
data[d] = wn.datetime.only_date(data[d]);
}
if (args[a].style == undefined) {
args[a].style = '';
}
data[d] = repl('\
<td width="%(width)s" title="%(title)s" style="%(style)s">\
%(content)s</td>',
{
content: data[d],
width: args[a].width,
title: args[a].label,
style: args[a].style,
});
content.push(data[d]);
break;
}
}
}
content = content.join("\n");
return '<table><tr>' + content + '</tr></table>';
}
cur_frm.cscript.get_query_transaction_history = function(args) {
var query = repl("\
select %(fields)s from `tab%(doctype)s` \
where %(parent)s = '%(parent_name)s' \
order by modified desc", args);
return query;
}

View File

@ -0,0 +1,161 @@
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.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);
data.creation = wn.datetime.str_to_user(data.communication_date);
data.content = cstr(data.subject) + " | " + cstr(data.content);
if(data.content && data.content.length > 50) {
data.content = '<span title="'+data.content+'">' +
data.description.substr(0,50) + '...</span>';
}
},
columns: [
{width: '3%', content: 'docstatus'},
{width: '15%', content: 'name'},
{width: '15%', content: 'category'},
{width: '55%', content: 'content'},
{width: '12%', content:'communication_date',
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()] = doc.name;
loaddoc(new_doc.doctype, new_doc.name);
});
}
// Render List
cur_frm.cscript.render_list = function(doc, doctype, wrapper, ListView,
new_doc_constructor) {
wn.model.with_doctype(doctype, function(r) {
if(r && r['403']) {
return;
}
var RecordListView = wn.views.RecordListView.extend({
default_docstatus: ['0', '1', '2'],
default_filters: [
[doctype, doc.doctype.toLowerCase(), '=', doc.name],
],
new_doc_constructor: new_doc_constructor || null,
});
var record_list_view = new RecordListView(doctype, wrapper, ListView);
});
}
// Transaction List related functions
cur_frm.cscript.render_list2 = function(parent, doc, doctype, args) {
$(parent).css({ 'padding-top': '10px' });
cur_frm.transaction_list = new wn.ui.Listing({
parent: parent,
page_length: 10,
get_query: function() {
return cur_frm.cscript.get_query_list({
parent: doc.doctype.toLowerCase(),
parent_name: doc.name,
doctype: doctype,
fields: (function() {
var fields = [];
for(var i in args) {
fields.push(args[i].fieldname);
}
return fields.join(", ");
})(),
});
},
as_dict: 1,
no_result_message: repl('No %(doctype)s created for this %(parent)s',
{ doctype: doctype, parent: doc.doctype }),
render_row: function(wrapper, data) {
render_html = cur_frm.cscript.render_list_row(data, args, doctype);
$(wrapper).html(render_html);
},
});
cur_frm.transaction_list.run();
}
cur_frm.cscript.render_list_row = function(data, args, doctype) {
var content = [];
var currency = data.currency;
for (var a in args) {
for (var d in data) {
if (args[a].fieldname === d && args[a].fieldname !== 'currency') {
if (args[a].type === 'Link') {
data[d] = repl('<a href="#!Form/%(doctype)s/%(name)s">\
%(name)s</a>', { doctype: doctype, name: data[d]});
} else if (args[a].type === 'Currency') {
data[d] = currency + " " + fmt_money(data[d]);
} else if (args[a].type === 'Percentage') {
data[d] = flt(data[d]) + '%';
} else if (args[a].type === 'Date') {
data[d] = wn.datetime.only_date(data[d]);
}
if (args[a].style == undefined) {
args[a].style = '';
}
data[d] = repl('\
<td width="%(width)s" title="%(title)s" style="%(style)s">\
%(content)s</td>',
{
content: data[d],
width: args[a].width,
title: args[a].label,
style: args[a].style,
});
content.push(data[d]);
break;
}
}
}
content = content.join("\n");
return '<table><tr>' + content + '</tr></table>';
}
cur_frm.cscript.get_query_list = function(args) {
var query = repl("\
select %(fields)s from `tab%(doctype)s` \
where %(parent)s = '%(parent_name)s' \
order by modified desc", args);
return query;
}

View File

@ -0,0 +1,26 @@
# 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 <http://www.gnu.org/licenses/>.
import webnotes
from webnotes.model.doc import make_autoname
class DocType():
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')

View File

@ -0,0 +1,396 @@
# DocType, Communication
[
# These values are common in all dictionaries
{
'creation': '2012-05-29 16:56:41',
'docstatus': 0,
'modified': '2012-05-31 14:46:44',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_attach': 1,
'description': u'Keep a track of all communications',
'doctype': 'DocType',
'module': u'Support',
'name': '__common__',
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Communication',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Communication',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1,
'write': 1
},
# DocType, Communication
{
'doctype': 'DocType',
'name': u'Communication'
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Support Team'
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales Manager'
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales User'
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Sales Manager'
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Support Manager'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'basic_info',
'fieldtype': u'Section Break',
'label': u'Basic Info',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'COMM-',
'doctype': u'DocField',
'fieldname': u'naming_series',
'fieldtype': u'Select',
'hidden': 1,
'label': u'Naming Series',
'options': u'COMM-',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'category',
'fieldtype': u'Select',
'label': u'Category',
'options': u'\nSales\nComplaint\nHelp\nSuggestion\nMiscellaneous',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'action',
'fieldtype': u'Select',
'label': u'Action',
'options': u'\nCreated Opportunity\nSent Quotation\nCreated Support Ticket\nCreated Customer Issue\nNo Action',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'subject',
'fieldtype': u'Small Text',
'label': u'Subject',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break1',
'fieldtype': u'Section Break',
'options': u'simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'content',
'fieldtype': u'Text Editor',
'label': u'Content',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'additional_info',
'fieldtype': u'Section Break',
'label': u'Additional Info',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'column_break3',
'fieldtype': u'Column Break',
'label': u'Communication With / Related To',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'lead',
'fieldtype': u'Link',
'hidden': 0,
'label': u'Lead',
'options': u'Lead',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'contact',
'fieldtype': u'Link',
'label': u'Contact',
'options': u'Contact',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'customer',
'fieldtype': u'Link',
'label': u'Customer',
'options': u'Customer',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'supplier',
'fieldtype': u'Link',
'label': u'Supplier',
'options': u'Supplier',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'opportunity',
'fieldtype': u'Link',
'label': u'Opportunity',
'options': u'Opportunity',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'quotation',
'fieldtype': u'Link',
'label': u'Quotation',
'options': u'Quotation',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'support_ticket',
'fieldtype': u'Link',
'label': u'Support Ticket',
'options': u'Support Ticket',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'next_action',
'fieldtype': u'Select',
'label': u'Next Action',
'options': u'\nFollow Up\nCreate Opportunity\nSend Quotation\nCreate Support Ticket\nCreate Customer Issue',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'next_action_date',
'fieldtype': u'Date',
'label': u'Next Action Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'medium',
'fieldtype': u'Select',
'label': u'Medium',
'options': u'\nChat\nPhone\nEmail\nSMS\nVisit\nOther',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'phone_no',
'fieldtype': u'Data',
'label': u'Phone No.',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'email_address',
'fieldtype': u'Data',
'label': u'Email Address',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break2',
'fieldtype': u'Section Break',
'options': u'simple',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break4',
'fieldtype': u'Column Break',
'label': u'Communication Carried Out By',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'__user',
'doctype': u'DocField',
'fieldname': u'profile',
'fieldtype': u'Link',
'label': u'Profile',
'options': u'Profile',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sales_person',
'fieldtype': u'Link',
'label': u'Sales Person',
'options': u'Sales Person',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break5',
'fieldtype': u'Column Break',
'label': u'Communication Carried Out On',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'Today',
'doctype': u'DocField',
'fieldname': u'communication_date',
'fieldtype': u'Date',
'label': u'Date',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
'label': u'File List',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'_user_tags',
'fieldtype': u'Data',
'hidden': 1,
'label': u'User Tags',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
}
]

View File

@ -0,0 +1,35 @@
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);
data.creation = wn.datetime.only_date(data.creation);
data.content = cstr(data.subject) + " | " + cstr(data.content);
if(data.content && data.content.length > 50) {
data.content = '<span title="'+data.content+'">' +
data.description.substr(0,50) + '...</span>';
}
},
columns: [
{width: '5%', content: 'avatar'},
{width: '3%', content: 'docstatus'},
{width: '15%', content: 'name'},
{width: '15%', content: 'category'},
{width: '55%', content: 'content+tags'},
{width: '12%', content:'creation',
css: {'text-align': 'right', 'color':'#777'}}
],
});

View File

@ -19,6 +19,9 @@
<div style="width: 48%; float: right;">
<h4><a href="#!List/Serial No">Serial No</a></h4>
<p class="help">Single unit of an Item</p>
<br>
<h4><a href="#!List/Communication">Communication</a></h4>
<p class="help">Communication Log</p>
</div>
<div style="clear: both"></div>
<hr>

View File

@ -305,7 +305,7 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico
if(icon){$('<i>').addClass(icon).appendTo($button);}
$button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');}
if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.new_doc_constructor?me.new_doc_constructor(me.new_doctype):newdoc(me.new_doctype);},'icon-plus');}
if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
this.onrun=a0;if(a0&&a0.callback)
@ -321,7 +321,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct
* lib/js/wn/ui/filters.js
*/
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
values.push(f.get_value());})
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)
@ -969,13 +969,13 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=d
<div style="clear: both"></div>\
</div>',{label:this.label}));this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('<span>').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,new_doc_constructor:this.new_doc_constructor||null,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){return repl('<div class="well"><p>No %(doctype_label)s found</p>\
%(description)s\
<hr>\
<p><button class="btn btn-info btn-small"\
onclick="newdoc(\'%(doctype)s\');"\
>Make a new %(doctype_label)s</button>\
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||null,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('<button class="btn btn-small"><i class="refresh"></i> Refresh</button>').click(function(){me.reload_stats();}).appendTo($('<div class="stat-wrapper">').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
@ -1023,6 +1023,7 @@ if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';da
for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('<br />');}
$.each(data._user_tags.split(','),function(i,t){if(t){$('<span class="label label-info" style="cursor: pointer; line-height: 200%">'
+strip(t)+'</span>').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}})
wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},});
/*
* lib/js/wn/views/formview.js
*/

View File

@ -192,7 +192,7 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico
if(icon){$('<i>').addClass(icon).appendTo($button);}
$button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');}
if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.new_doc_constructor?me.new_doc_constructor(me.new_doctype):newdoc(me.new_doctype);},'icon-plus');}
if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
this.onrun=a0;if(a0&&a0.callback)
@ -208,7 +208,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct
* lib/js/wn/ui/filters.js
*/
wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
values.push(f.get_value());})
return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)