Merge branch 'master' of github.com:webnotes/erpnext into stock_reco

This commit is contained in:
Anand Doshi
2013-01-10 14:38:08 +05:30
48 changed files with 1599 additions and 1506 deletions

View File

@@ -25,6 +25,9 @@ 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);
}
cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
}
// ONLOAD
@@ -79,7 +82,7 @@ cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
}
// hide - unhide fields based on lead or customer
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
if(doc.enquiry_from == 'Lead'){
unhide_field(['lead']);
hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
@@ -87,13 +90,15 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
}
else if(doc.enquiry_from == 'Customer'){
unhide_field(['customer']);
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory', 'customer_group']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
}
// customer
cur_frm.cscript.customer = function(doc,dt,dn) {
cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
if(doc.customer) {
cur_frm.call({
doc: cur_frm.doc,
@@ -127,11 +132,18 @@ cur_frm.fields_dict.contact_person.on_new = function(dn) {
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
return 'SELECT name, address_line1, city FROM tabAddress \
WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND \
%(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
if (!doc.customer) msgprint("Please select customer first");
else {
return 'SELECT name, CONCAT(first_name," ",ifnull(last_name,"")) As FullName, \
department, designation FROM tabContact WHERE customer = "'+ doc.customer +
'" AND docstatus != 2 AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}
}
// lead
@@ -140,6 +152,8 @@ cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
}
cur_frm.cscript.lead = function(doc, cdt, cdn) {
cur_frm.toggle_display("contact_info", doc.customer || doc.lead);
if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
}

View File

@@ -93,9 +93,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}
erpnext.hide_naming_series();
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);
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
if (!doc.__islocal) {
cur_frm.communication_view = new wn.views.CommunicationList({
@@ -120,6 +118,8 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','territory', 'customer_group']);
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
@@ -130,27 +130,11 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
cur_frm.cscript.lead = function(doc, cdt, cdn) {
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
if(doc.lead) {
get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
unhide_field('territory');

View File

@@ -320,7 +320,27 @@ cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field('batch_no').get_query
}
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name, address_line1, city FROM tabAddress \
WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND \
%(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name, CONCAT(first_name," ",ifnull(last_name,"")) As FullName, \
department, designation FROM tabContact WHERE customer = "'+ doc.customer +
'" AND docstatus != 2 AND %(key)s LIKE "%s" ORDER BY name ASC LIMIT 50';
}
// *********************** QUANTITY ***************************
cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }

View File

@@ -36,7 +36,9 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
// load default charges
if(doc.__islocal && !doc.customer){
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
hide_field(['customer_address','contact_person', 'customer_name',
'address_display', 'contact_display', 'contact_mobile',
'contact_email', 'territory', 'customer_group']);
}
}
@@ -59,9 +61,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
if(doc.customer) $(cur_frm.fields_dict.contact_info.row.wrapper).toggle(true);
else $(cur_frm.fields_dict.contact_info.row.wrapper).toggle(false);
cur_frm.toggle_display("contact_info", doc.customer);
if(doc.docstatus==1) {
if(doc.status != 'Stopped') {
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
@@ -105,11 +106,13 @@ cur_frm.cscript.order_type = function(doc) {
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
cur_frm.toggle_display("contact_info", doc.customer);
var pl = doc.price_list_name;
var callback = function(r,rt) {
var callback2 = function(r, rt) {
if(doc.customer) unhide_field(['customer_address', 'contact_person', 'territory','customer_group']);
if(doc.customer)
unhide_field(['customer_address', 'contact_person', 'territory','customer_group']);
cur_frm.refresh();
if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn);
@@ -119,38 +122,22 @@ cur_frm.cscript.customer = function(doc,dt,dn) {
get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0, callback2);
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
'get_default_customer_address', '', callback);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) {
var callback = function(r,rt){
var doc = locals[cur_frm.doctype][cur_frm.docname];
if(!r.exc){
doc.quotation_no = r.message;
if(doc.quotation_no) {
unhide_field(['quotation_date', 'customer_address', 'contact_person', 'territory', 'customer_group']);
unhide_field(['quotation_date', 'customer_address',
'contact_person', 'territory', 'customer_group']);
if(doc.customer) get_server_fields('get_shipping_address', doc.customer, '', doc, dt, dn, 0);
}
cur_frm.refresh();

View File

@@ -13,7 +13,7 @@ def get_children():
if(is_group='Yes', 1, 0) as expandable
from `tab%(ctype)s`
where docstatus < 2
and %(parent_field)s = "%(parent)s"
and ifnull(%(parent_field)s,'') = "%(parent)s"
order by name""" % webnotes.form_dict, as_dict=1)
@webnotes.whitelist()

View File

@@ -1,136 +0,0 @@
<div class="layout-wrapper layout-wrapper-background">
<div class="appframe-area"></div>
<div class="layout-main-section">
<div style="width: 48%; float: left;">
<h5><a href="#List/Lead">Lead</a></h5>
<p class="help">Prospective customers</p>
<br>
<h5><a href="#List/Opportunity">Opportunity</a></h5>
<p class="help">Business opportunities</p>
<br>
<h5><a href="#List/Quotation">Quotation</a></h5>
<p class="help">Quotes sent to Leads / Customers</p>
<br>
<h5><a href="#List/Sales Order">Sales Order</a></h5>
<p class="help">Confirmed orders from Customers</p>
<br>
<h5><a href="#List/Communication">Communication</a></h5>
<p class="help">All communication records</p>
</div>
<div style="width: 48%; float: right;">
<h5><a href="#List/Customer">Customer</a></h5>
<p class="help">Customer Master</p>
<br>
<h5><a href="#List/Item">Item</a></h5>
<p class="help">Item Master</p>
<br>
<h5><a href="#List/Contact">Contact</a></h5>
<p class="help">Contact Master</p>
<br>
<h5><a href="#List/Address">Address</a></h5>
<p class="help">Address Master</p>
</div>
<div style="clear: both"></div>
<hr>
<h4>Reports</h4>
<div style="width: 48%; float: left;">
<h5><a href="#sales-analytics" data-role="Analytics, Sales Manager,
Maintenance Manager">Sales Analytics</a>
</h5>
<p class="help">Sales trends based on Sales Invoice</p>
</div>
<div style="width: 48%; float: right;">
</div>
<div style="clear: both;"></div>
<hr>
<div class="reports-list"></div>
</div>
<div class="layout-side-section">
<div class="psidebar">
<div class="section">
<div class="section-head">Setup</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title = "Tax and charges structure master"
href="#List/Sales Taxes and Charges Master">Sales Taxes and Charges Master</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Multiple prices lists for items"
href="#List/Price List">Price List</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Group items and accessories in one item code"
href="#List/Sales BOM">Sales BOM</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Terms of contract template"
href="#List/Terms and Conditions">Terms and Conditions Template</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tree of customer groups"
href="#Sales Browser/Customer Group"
data-role="Sales Manager, Sales Master Manager,
Accounts Manager">Customer Group</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tree of sales territories"
href="#Sales Browser/Territory"
data-role="Sales Manager, Sales Master Manager
Accounts Manager">Territory</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Sales persons and targets"
href="#Sales Browser/Sales Person"
data-role="Sales Manager, Sales Master Manager
Accounts Manager">Sales Person</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Commission partners and targets"
href="#List/Sales Partner">Sales Partner</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tree of item classification"
href="#Sales Browser/Item Group"
data-role="Sales Manager, Sales Master Manager
Accounts Manager">Item Group</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Sales campaigns"
href="#List/Campaign">Campaign</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Send mass SMS to your contacts, leads and employees"
href="#Form/SMS Center/SMS Center">SMS Center</a>
</div>
</div>
</div>
<div class="section">
<div class="section-head">Tools</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title = "Helper for managing return of goods (sales or purchase)"
href="#Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales Returns</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
href="#Report/Profile/Trend Analyzer">Trend Analyzer</a>
</div>
</div>
</div>
</div>
</div>
<div style="clear: both;"></div>
</div>

View File

@@ -1,20 +1,167 @@
// 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/>.
// ERPNext: Copyright 2013 Web Notes Technologies Pvt Ltd
// GNU General Public License. See "license.txt"
wn.module_page["Selling"] = [
{
title: wn._("Documents"),
icon: "icon-copy",
items: [
{
label: wn._("Lead"),
description: wn._("Database of potential customers."),
doctype:"Lead"
},
{
label: wn._("Opportunity"),
description: wn._("Potential opportunities for selling."),
doctype:"Opportunity"
},
{
label: wn._("Quotation"),
description: wn._("Quotes to Leads or Customers."),
doctype:"Quotation"
},
{
label: wn._("Sales Order"),
description: wn._("Confirmed orders from Customers."),
doctype:"Sales Order"
},
]
},
{
title: wn._("Masters"),
icon: "icon-book",
items: [
{
label: wn._("Customer"),
description: wn._("Customer database."),
doctype:"Customer"
},
{
label: wn._("Contact"),
description: wn._("All Contacts."),
doctype:"Contact"
},
{
label: wn._("Address"),
description: wn._("All Addresses."),
doctype:"Address"
},
{
label: wn._("Item"),
description: wn._("All Products or Services."),
doctype:"Item"
},
]
},
{
title: wn._("Setup"),
icon: "icon-cog",
items: [
{
label: wn._("Sales Taxes and Charges Master"),
description: wn._("Sales taxes template."),
doctype:"Sales Taxes and Charges Master"
},
{
label: wn._("Price List"),
description: wn._("Mupltiple Item prices."),
doctype:"Price List"
},
{
label: wn._("Sales BOM"),
description: wn._("Bundle items at time of sale."),
doctype:"Sales BOM"
},
{
label: wn._("Terms and Conditions"),
description: wn._("Template of terms or contract."),
doctype:"Terms and Conditions"
},
{
label: wn._("Customer Group"),
description: wn._("Customer classification tree."),
route: "Sales Browser/Customer Group",
doctype:"Customer Group"
},
{
label: wn._("Territory"),
description: wn._("Sales territories."),
route: "Sales Browser/Territory",
doctype:"Territory"
},
{
"route":"Sales Browser/Sales Person",
"label":wn._("Sales Person"),
"description": wn._("Sales persons and targets"),
doctype:"Sales Person"
},
{
"route":"List/Sales Partner",
"label": wn._("Sales Partner"),
"description":wn._("Commission partners and targets"),
doctype:"Sales Partner"
},
{
"route":"Sales Browser/Item Group",
"label":wn._("Item Group"),
"description": wn._("Tree of item classification"),
doctype:"Item Group"
},
{
"route":"List/Campaign",
"label":wn._("Campaign"),
"description":wn._("Sales campaigns"),
doctype:"Campaign"
},
]
},
{
title: wn._("Tools"),
icon: "icon-wrench",
items: [
{
"route":"Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool",
"label":wn._("Sales Returns"),
"description":wn._("Helper for managing return of goods (sales or purchase)"),
doctype: "Sales and Purchase Return Tool"
},
{
"route":"Form/SMS Center/SMS Center",
"label":wn._("SMS Center"),
"description":wn._("Send mass SMS to your contacts"),
doctype:"SMS Center"
},
]
},
{
title: wn._("Analytics"),
right: true,
icon: "icon-bar-chart",
items: [
{
"label":wn._("Sales Analytics"),
page: "sales-analytics"
},
]
},
{
title: wn._("Reports"),
right: true,
icon: "icon-list",
items: [
{
"label":wn._("Customer Addresses and Contacts"),
route: "query-report/Customer Addresses and Contacts"
},
{
"label":wn._("Sales Orders Pending to be Delivered"),
route: "query-report/Sales Orders Pending to be Delivered"
},
]
}
]
pscript['onload_selling-home'] = function(wrapper) {
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Selling');
erpnext.module_page.setup_page('Selling', wrapper);
wn.views.moduleview.make(wrapper, "Selling");
}