[forms] cleanup, fixing usability and added form dashboard
This commit is contained in:
parent
d420401ba3
commit
2eb7ceabda
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-10 16:34:16",
|
"creation": "2013-01-10 16:34:16",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-01-29 17:17:31",
|
"modified": "2013-07-02 11:56:54",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -106,6 +106,14 @@
|
|||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "wip_warehouse",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Work-in-Progress Warehouse",
|
||||||
|
"options": "Warehouse",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "column_break1",
|
"fieldname": "column_break1",
|
||||||
@ -172,6 +180,13 @@
|
|||||||
"options": "Sales Order",
|
"options": "Sales Order",
|
||||||
"read_only": 0
|
"read_only": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Item Description",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "project_name",
|
"fieldname": "project_name",
|
||||||
|
@ -210,7 +210,6 @@ class DocType:
|
|||||||
"wip_warehouse" : "",
|
"wip_warehouse" : "",
|
||||||
"fg_warehouse" : "",
|
"fg_warehouse" : "",
|
||||||
"status" : "Draft",
|
"status" : "Draft",
|
||||||
"fiscal_year" : webnotes.conn.get_default("fiscal_year")
|
|
||||||
}
|
}
|
||||||
return bom_dict, item_dict
|
return bom_dict, item_dict
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
|
|||||||
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||||
|
cur_frm.layout.clear_dashboard();
|
||||||
if(sys_defaults.cust_master_name == 'Customer Name')
|
if(sys_defaults.cust_master_name == 'Customer Name')
|
||||||
hide_field('naming_series');
|
hide_field('naming_series');
|
||||||
else
|
else
|
||||||
@ -40,6 +41,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
|
|||||||
if(doc.__islocal){
|
if(doc.__islocal){
|
||||||
hide_field(['address_html','contact_html']);
|
hide_field(['address_html','contact_html']);
|
||||||
}else{
|
}else{
|
||||||
|
cur_frm.cscript.setup_dashboard(doc);
|
||||||
unhide_field(['address_html','contact_html']);
|
unhide_field(['address_html','contact_html']);
|
||||||
// make lists
|
// make lists
|
||||||
cur_frm.cscript.make_address(doc,dt,dn);
|
cur_frm.cscript.make_address(doc,dt,dn);
|
||||||
@ -53,6 +55,35 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.setup_dashboard = function(doc) {
|
||||||
|
cur_frm.layout.dashboard.toggle(true);
|
||||||
|
var headline = $('<div class="form-headline col col-lg-12">\
|
||||||
|
<span class="text-muted">Loading...</span></div>')
|
||||||
|
.appendTo(cur_frm.layout.dashboard);
|
||||||
|
|
||||||
|
cur_frm.layout.add_doctype_badge(wn._("Opportunities"), "Opportunity", "customer");
|
||||||
|
cur_frm.layout.add_doctype_badge(wn._("Quotations"), "Quotation", "customer");
|
||||||
|
cur_frm.layout.add_doctype_badge(wn._("Sales Orders"), "Sales Order", "customer");
|
||||||
|
cur_frm.layout.add_doctype_badge(wn._("Delivery Notes"), "Delivery Note", "customer");
|
||||||
|
cur_frm.layout.add_doctype_badge(wn._("Sales Invoices"), "Sales Invoice", "customer");
|
||||||
|
|
||||||
|
wn.call({
|
||||||
|
type: "GET",
|
||||||
|
method:"selling.doctype.customer.customer.get_dashboard_info",
|
||||||
|
args: {
|
||||||
|
customer: cur_frm.doc.name
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
cur_frm.layout.dashboard.find(".form-headline")
|
||||||
|
.html(wn._("Total Billing This Year: ") + "<b>"
|
||||||
|
+ format_currency(r.message.total_billing, cur_frm.doc.default_currency)
|
||||||
|
+ '</b> / <span class="text-muted">' + wn._("Unpaid") + ": <b>" +
|
||||||
|
format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) + '</b></span>');
|
||||||
|
cur_frm.layout.set_badge_count(r.message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
cur_frm.cscript.make_address = function() {
|
cur_frm.cscript.make_address = function() {
|
||||||
if(!cur_frm.address_list) {
|
if(!cur_frm.address_list) {
|
||||||
cur_frm.address_list = new wn.ui.Listing({
|
cur_frm.address_list = new wn.ui.Listing({
|
||||||
|
@ -174,3 +174,24 @@ class DocType(TransactionBase):
|
|||||||
#update master_name in doctype account
|
#update master_name in doctype account
|
||||||
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
|
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
|
||||||
master_type = 'Customer' where master_name = %s""", (new,old))
|
master_type = 'Customer' where master_name = %s""", (new,old))
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_dashboard_info(customer):
|
||||||
|
if not webnotes.has_permission("Customer", customer):
|
||||||
|
webnotes.msgprint("No Permission", raise_exception=True)
|
||||||
|
|
||||||
|
out = {}
|
||||||
|
for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
|
||||||
|
out[doctype] = webnotes.conn.get_value(doctype,
|
||||||
|
{"customer": customer, "docstatus": ["!=", 2] }, "count(*)")
|
||||||
|
|
||||||
|
billing = webnotes.conn.sql("""select sum(grand_total), sum(outstanding_amount)
|
||||||
|
from `tabSales Invoice`
|
||||||
|
where customer=%s
|
||||||
|
and docstatus = 1
|
||||||
|
and fiscal_year = %s""", (customer, webnotes.conn.get_default("fiscal_year")))
|
||||||
|
|
||||||
|
out["total_billing"] = billing[0][0]
|
||||||
|
out["total_unpaid"] = billing[0][1]
|
||||||
|
|
||||||
|
return out
|
@ -34,11 +34,21 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
|
|||||||
// ===============================================================
|
// ===============================================================
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||||
|
|
||||||
if(!doc.enquiry_from) hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
|
if(!doc.enquiry_from && doc.customer)
|
||||||
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
|
doc.enquiry_from = "Customer";
|
||||||
if(!doc.date) doc.transaction_date = date.obj_to_str(new Date());
|
if(!doc.enquiry_from && doc.lead)
|
||||||
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
|
doc.enquiry_from = "Lead";
|
||||||
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
|
|
||||||
|
if(!doc.enquiry_from)
|
||||||
|
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
|
||||||
|
if(!doc.status)
|
||||||
|
set_multiple(cdt,cdn,{status:'Draft'});
|
||||||
|
if(!doc.date)
|
||||||
|
doc.transaction_date = date.obj_to_str(new Date());
|
||||||
|
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.enquiry_from) {
|
if(doc.enquiry_from) {
|
||||||
if(doc.enquiry_from == 'Customer') {
|
if(doc.enquiry_from == 'Customer') {
|
||||||
@ -61,6 +71,8 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
|||||||
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
|
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
|
||||||
cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query;
|
cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(doc.customer && !doc.customer_name) cur_frm.cscript.customer(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-07 18:50:30",
|
"creation": "2013-03-07 18:50:30",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-06-11 16:03:41",
|
"modified": "2013-07-02 17:22:21",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -43,6 +43,12 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"name": "Opportunity"
|
"name": "Opportunity"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "from_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "From"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
@ -26,8 +26,16 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
|
|||||||
wn.require('app/selling/doctype/sales_common/sales_common.js');
|
wn.require('app/selling/doctype/sales_common/sales_common.js');
|
||||||
|
|
||||||
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||||
|
onload: function(doc, dt, dn) {
|
||||||
|
this._super(doc, dt, dn);
|
||||||
|
if(doc.customer && !doc.quotation_to)
|
||||||
|
doc.quotation_to = "Customer";
|
||||||
|
else if(doc.lead && !doc.quotation_to)
|
||||||
|
doc.quotation_to = "Lead";
|
||||||
|
|
||||||
|
},
|
||||||
refresh: function(doc, dt, dn) {
|
refresh: function(doc, dt, dn) {
|
||||||
this._super();
|
this._super(doc, dt, dn);
|
||||||
|
|
||||||
if(doc.docstatus == 1 && doc.status!='Order Lost') {
|
if(doc.docstatus == 1 && doc.status!='Order Lost') {
|
||||||
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
|
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-05-24 19:29:08",
|
"creation": "2013-05-24 19:29:08",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-06-28 12:47:10",
|
"modified": "2013-07-02 16:49:52",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@ -42,6 +42,12 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"name": "Quotation"
|
"name": "Quotation"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "customer_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Customer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "column_break0",
|
"fieldname": "column_break0",
|
||||||
|
@ -7,6 +7,11 @@ wn.module_page["Selling"] = [
|
|||||||
title: wn._("Documents"),
|
title: wn._("Documents"),
|
||||||
icon: "icon-copy",
|
icon: "icon-copy",
|
||||||
items: [
|
items: [
|
||||||
|
{
|
||||||
|
label: wn._("Customer"),
|
||||||
|
description: wn._("Customer database."),
|
||||||
|
doctype:"Customer"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: wn._("Lead"),
|
label: wn._("Lead"),
|
||||||
description: wn._("Database of potential customers."),
|
description: wn._("Database of potential customers."),
|
||||||
@ -33,11 +38,6 @@ wn.module_page["Selling"] = [
|
|||||||
title: wn._("Masters"),
|
title: wn._("Masters"),
|
||||||
icon: "icon-book",
|
icon: "icon-book",
|
||||||
items: [
|
items: [
|
||||||
{
|
|
||||||
label: wn._("Customer"),
|
|
||||||
description: wn._("Customer database."),
|
|
||||||
doctype:"Customer"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: wn._("Contact"),
|
label: wn._("Contact"),
|
||||||
description: wn._("All Contacts."),
|
description: wn._("All Contacts."),
|
||||||
|
Loading…
Reference in New Issue
Block a user