mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
[form] added icon in section break
This commit is contained in:
@@ -21,15 +21,16 @@ cur_frm.cscript.onload = function(doc,dt,dn){
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||
if(sys_defaults.supp_master_name == 'Supplier Name')
|
||||
hide_field('naming_series');
|
||||
else
|
||||
unhide_field('naming_series');
|
||||
cur_frm.cscript.setup_dashboard(doc);
|
||||
if(sys_defaults.supp_master_name == 'Supplier Name')
|
||||
hide_field('naming_series');
|
||||
else
|
||||
unhide_field('naming_series');
|
||||
|
||||
if(doc.__islocal){
|
||||
if(doc.__islocal){
|
||||
hide_field(['address_html','contact_html']);
|
||||
}
|
||||
else{
|
||||
}
|
||||
else{
|
||||
unhide_field(['address_html','contact_html']);
|
||||
// make lists
|
||||
cur_frm.cscript.make_address(doc,dt,dn);
|
||||
@@ -43,6 +44,36 @@ cur_frm.cscript.refresh = function(doc,dt,dn) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.setup_dashboard = function(doc) {
|
||||
cur_frm.layout.dashboard.empty().toggle(doc.__islocal ? false : true);
|
||||
if(doc.__islocal)
|
||||
return;
|
||||
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("Supplier Quotation", "supplier");
|
||||
cur_frm.layout.add_doctype_badge("Purchase Order", "supplier");
|
||||
cur_frm.layout.add_doctype_badge("Purchase Receipt", "supplier");
|
||||
cur_frm.layout.add_doctype_badge("Purchase Invoice", "supplier");
|
||||
|
||||
wn.call({
|
||||
type: "GET",
|
||||
method:"buying.doctype.supplier.supplier.get_dashboard_info",
|
||||
args: {
|
||||
supplier: 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() {
|
||||
if(!cur_frm.address_list) {
|
||||
cur_frm.address_list = new wn.ui.Listing({
|
||||
|
||||
@@ -193,3 +193,24 @@ class DocType(TransactionBase):
|
||||
#update master_name in doctype account
|
||||
webnotes.conn.sql("""update `tabAccount` set master_name = %s,
|
||||
master_type = 'Supplier' where master_name = %s""" , (new,old))
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_dashboard_info(supplier):
|
||||
if not webnotes.has_permission("Supplier", supplier):
|
||||
webnotes.msgprint("No Permission", raise_exception=True)
|
||||
|
||||
out = {}
|
||||
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
|
||||
out[doctype] = webnotes.conn.get_value(doctype,
|
||||
{"supplier": supplier, "docstatus": ["!=", 2] }, "count(*)")
|
||||
|
||||
billing = webnotes.conn.sql("""select sum(grand_total), sum(outstanding_amount)
|
||||
from `tabPurchase Invoice`
|
||||
where supplier=%s
|
||||
and docstatus = 1
|
||||
and fiscal_year = %s""", (supplier, webnotes.conn.get_default("fiscal_year")))
|
||||
|
||||
out["total_billing"] = billing[0][0]
|
||||
out["total_unpaid"] = billing[0][1]
|
||||
|
||||
return out
|
||||
@@ -7,6 +7,11 @@ wn.module_page["Buying"] = [
|
||||
top: true,
|
||||
icon: "icon-copy",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Supplier"),
|
||||
description: wn._("Supplier database."),
|
||||
doctype:"Supplier"
|
||||
},
|
||||
{
|
||||
label: wn._("Material Request"),
|
||||
description: wn._("Request for purchase."),
|
||||
@@ -28,11 +33,6 @@ wn.module_page["Buying"] = [
|
||||
title: wn._("Masters"),
|
||||
icon: "icon-book",
|
||||
items: [
|
||||
{
|
||||
label: wn._("Supplier"),
|
||||
description: wn._("Supplier database."),
|
||||
doctype:"Supplier"
|
||||
},
|
||||
{
|
||||
label: wn._("Contact"),
|
||||
description: wn._("All Contacts."),
|
||||
|
||||
Reference in New Issue
Block a user