[fix] [minor] show stock ledger, general ledger, fixes post changes in script manager trigger [issue] webnotes/wnframework#228
This commit is contained in:
parent
7180eb6f20
commit
a648f46d4e
@ -18,10 +18,20 @@ wn.provide("erpnext.accounts");
|
||||
|
||||
erpnext.accounts.JournalVoucher = wn.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
this.load_defaults(this.frm.doc);
|
||||
this.load_defaults();
|
||||
this.setup_queries();
|
||||
},
|
||||
|
||||
load_defaults: function() {
|
||||
if(this.frm.doc.__islocal && this.frm.doc.company) {
|
||||
wn.model.set_default_values(this.frm.doc);
|
||||
$.each(wn.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: "entries"}),
|
||||
function(i, jvd) { wn.model.set_default_values(jvd); });
|
||||
|
||||
this.frm.doc.posting_date = get_today();
|
||||
}
|
||||
},
|
||||
|
||||
setup_queries: function() {
|
||||
var me = this;
|
||||
|
||||
@ -82,23 +92,6 @@ cur_frm.cscript.refresh = function(doc) {
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.load_defaults = function(doc) {
|
||||
if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; }
|
||||
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
var fields_to_refresh = wn.model.set_default_values(doc);
|
||||
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
|
||||
|
||||
fields_to_refresh = null;
|
||||
var children = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||
if(!children) { return; }
|
||||
for(var i=0; i<children.length; i++) {
|
||||
wn.model.set_default_values(children[i]);
|
||||
}
|
||||
refresh_field('entries');
|
||||
}
|
||||
|
||||
|
||||
cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
|
||||
hide_field('aging_date');
|
||||
if (doc.is_opening == 'Yes') unhide_field('aging_date');
|
||||
|
@ -133,6 +133,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
},
|
||||
|
||||
is_pos: function() {
|
||||
cur_frm.cscript.hide_fields(this.frm.doc);
|
||||
|
||||
if(cint(this.frm.doc.is_pos)) {
|
||||
if(!this.frm.doc.company) {
|
||||
this.frm.set_value("is_pos", 0);
|
||||
@ -145,9 +147,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO toggle display of fields
|
||||
cur_frm.cscript.hide_fields(this.frm.doc);
|
||||
},
|
||||
|
||||
debit_to: function() {
|
||||
@ -191,8 +190,7 @@ $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_
|
||||
// Hide Fields
|
||||
// ------------
|
||||
cur_frm.cscript.hide_fields = function(doc) {
|
||||
par_flds = ['project_name', 'due_date', 'is_opening', 'conversion_rate',
|
||||
'source', 'total_advance', 'gross_profit',
|
||||
par_flds = ['project_name', 'due_date', 'is_opening', 'source', 'total_advance', 'gross_profit',
|
||||
'gross_profit_percent', 'get_advances_received',
|
||||
'advance_adjustment_details', 'sales_partner', 'commission_rate',
|
||||
'total_commission', 'advances'];
|
||||
|
@ -63,6 +63,12 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) {
|
||||
cur_frm.set_value("approval_status", "Draft");
|
||||
cur_frm.cscript.clear_sanctioned(doc);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
query:"controllers.queries.employee_query"
|
||||
}
|
||||
}
|
||||
|
||||
return cur_frm.call({
|
||||
method:"hr.utils.get_expense_approver_list",
|
||||
@ -70,12 +76,6 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) {
|
||||
cur_frm.set_df_property("exp_approver", "options", r.message);
|
||||
}
|
||||
});
|
||||
|
||||
cur_frm.fields_dict.employee.get_query = function(doc,cdt,cdn) {
|
||||
return{
|
||||
query:"controllers.queries.employee_query"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.clear_sanctioned = function(doc) {
|
||||
|
@ -54,7 +54,7 @@ $.extend(erpnext.complete_setup, {
|
||||
$('header').toggle(false); // hide toolbar
|
||||
}
|
||||
|
||||
return wn.call({
|
||||
wn.call({
|
||||
method:"webnotes.country_info.get_country_timezone_info",
|
||||
callback: function(data) {
|
||||
erpnext.country_info = data.message.country_info;
|
||||
|
@ -19,22 +19,26 @@ wn.provide("erpnext.stock");
|
||||
erpnext.stock.StockController = wn.ui.form.Controller.extend({
|
||||
show_stock_ledger: function() {
|
||||
var me = this;
|
||||
this.frm.add_custom_button("Stock Ledger", function() {
|
||||
wn.route_options = {
|
||||
voucher_no: me.frm.doc.name,
|
||||
from_date: cur_frm.doc.posting_date,
|
||||
to_date: cur_frm.doc.posting_date
|
||||
};
|
||||
wn.set_route('stock-ledger');
|
||||
}, "icon-bar-chart");
|
||||
if(this.frm.doc.docstatus===1) {
|
||||
this.frm.add_custom_button("Stock Ledger", function() {
|
||||
wn.route_options = {
|
||||
voucher_no: me.frm.doc.name,
|
||||
from_date: me.frm.doc.posting_date,
|
||||
to_date: me.frm.doc.posting_date
|
||||
};
|
||||
wn.set_route('stock-ledger');
|
||||
}, "icon-bar-chart");
|
||||
}
|
||||
|
||||
},
|
||||
show_general_ledger: function() {
|
||||
if(doc.docstatus==1) {
|
||||
var me = this;
|
||||
if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("auto_inventory_accounting"))) {
|
||||
cur_frm.add_custom_button('Accounting Ledger', function() {
|
||||
wn.route_options = {
|
||||
"voucher_no": doc.name,
|
||||
"from_date": doc.posting_date,
|
||||
"to_date": doc.posting_date,
|
||||
"voucher_no": me.frm.doc.name,
|
||||
"from_date": me.frm.doc.posting_date,
|
||||
"to_date": me.frm.doc.posting_date,
|
||||
};
|
||||
wn.set_route("general-ledger");
|
||||
});
|
||||
|
@ -15,8 +15,9 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
wn.provide("erpnext");
|
||||
wn.require("app/js/controllers/stock_controller.js");
|
||||
|
||||
erpnext.TransactionController = wn.ui.form.Controller.extend({
|
||||
erpnext.TransactionController = erpnext.stock.StockController.extend({
|
||||
onload: function() {
|
||||
if(this.frm.doc.__islocal) {
|
||||
var me = this,
|
||||
|
@ -86,15 +86,15 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
|
||||
customer: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.customer) {
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "set_customer_defaults",
|
||||
});
|
||||
|
||||
// TODO shift this to depends_on
|
||||
unhide_field(['customer_address', 'contact_person', 'customer_name',
|
||||
'address_display', 'contact_display', 'contact_mobile', 'contact_email',
|
||||
'territory', 'customer_group']);
|
||||
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "set_customer_defaults",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -114,6 +114,7 @@ cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
|
||||
|
||||
cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
if(doc.lead) {
|
||||
unhide_field('territory');
|
||||
return cur_frm.call({
|
||||
doc: cur_frm.doc,
|
||||
method: "set_lead_defaults",
|
||||
@ -123,7 +124,6 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) {
|
||||
}
|
||||
}
|
||||
});
|
||||
unhide_field('territory');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,36 +21,7 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
completed = 0;
|
||||
|
||||
body.html('<div class="progress progress-striped active">\
|
||||
<div class="progress-bar" style="width: 100%;"></div></div>')
|
||||
|
||||
return wn.call({
|
||||
method: "setup.page.setup.setup.get",
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
body.empty();
|
||||
if(wn.boot.expires_on) {
|
||||
$(body).prepend("<div class='text-muted' style='text-align:right'>Account expires on "
|
||||
+ wn.datetime.global_date_format(wn.boot.expires_on) + "</div>");
|
||||
}
|
||||
|
||||
$completed = $('<h4>Setup Completed <span class="completed-percent"></span><h4>\
|
||||
<div class="progress"><div class="progress-bar"></div></div>')
|
||||
.appendTo(body);
|
||||
|
||||
$.each(r.message, function(i, item) {
|
||||
render_item(item)
|
||||
});
|
||||
|
||||
var completed_percent = cint(flt(completed) / total * 100) + "%";
|
||||
$completed
|
||||
.find(".progress-bar")
|
||||
.css({"width": completed_percent});
|
||||
$(body)
|
||||
.find(".completed-percent")
|
||||
.html("(" + completed_percent + ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
<div class="progress-bar" style="width: 100%;"></div></div>');
|
||||
|
||||
var render_item = function(item, dependency) {
|
||||
if(item.type==="Section") {
|
||||
@ -68,12 +39,12 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
.appendTo(body);
|
||||
|
||||
$('<div class="col col-lg-1"></div>').appendTo(row);
|
||||
|
||||
|
||||
if(item.type==="Link") {
|
||||
var col = $('<div class="col col-lg-5"><b><a href="#'
|
||||
+item.route+'"><i class="'+item.icon+'"></i> '
|
||||
+item.title+'</a></b></div>').appendTo(row);
|
||||
|
||||
|
||||
} else {
|
||||
var col = $(repl('<div class="col col-lg-5">\
|
||||
<span class="badge view-link">%(count)s</span>\
|
||||
@ -102,12 +73,12 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
col.addClass("col-offset-1");
|
||||
else
|
||||
$('<div class="col col-lg-1"></div>').appendTo(row);
|
||||
|
||||
|
||||
if(item.doctype) {
|
||||
var badge = col.find(".badge, .data-link")
|
||||
.attr("data-doctype", item.doctype)
|
||||
.css({"cursor": "pointer"})
|
||||
|
||||
|
||||
if(item.single) {
|
||||
badge.click(function() {
|
||||
wn.set_route("Form", $(this).attr("data-doctype"))
|
||||
@ -118,10 +89,10 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// tree
|
||||
$links = $('<div class="col col-lg-5">').appendTo(row);
|
||||
|
||||
|
||||
if(item.tree) {
|
||||
$('<a class="view-link"><i class="icon-sitemap"></i> Browse</a>\
|
||||
<span class="text-muted">|</span> \
|
||||
@ -134,7 +105,7 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
mylink.click(function() {
|
||||
wn.set_route(item.tree, item.doctype);
|
||||
})
|
||||
|
||||
|
||||
} else if(item.single) {
|
||||
$('<a class="view-link"><i class="icon-edit"></i> Edit</a>')
|
||||
.appendTo($links)
|
||||
@ -183,7 +154,7 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
wn.route_options = {doctype:$(this).attr("data-doctype")}
|
||||
wn.set_route("data-import-tool");
|
||||
})
|
||||
|
||||
|
||||
if(item.links) {
|
||||
$.each(item.links, function(i, link) {
|
||||
var newlinks = $('<span class="text-muted"> |</span> \
|
||||
@ -192,11 +163,40 @@ wn.pages.Setup.make = function(wrapper) {
|
||||
.appendTo($links)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
if(item.dependencies) {
|
||||
$.each(item.dependencies, function(i, d) {
|
||||
render_item(d, true);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return wn.call({
|
||||
method: "setup.page.setup.setup.get",
|
||||
callback: function(r) {
|
||||
if(r.message) {
|
||||
body.empty();
|
||||
if(wn.boot.expires_on) {
|
||||
$(body).prepend("<div class='text-muted' style='text-align:right'>Account expires on "
|
||||
+ wn.datetime.global_date_format(wn.boot.expires_on) + "</div>");
|
||||
}
|
||||
|
||||
$completed = $('<h4>Setup Completed <span class="completed-percent"></span><h4>\
|
||||
<div class="progress"><div class="progress-bar"></div></div>')
|
||||
.appendTo(body);
|
||||
|
||||
$.each(r.message, function(i, item) {
|
||||
render_item(item)
|
||||
});
|
||||
|
||||
var completed_percent = cint(flt(completed) / total * 100) + "%";
|
||||
$completed
|
||||
.find(".progress-bar")
|
||||
.css({"width": completed_percent});
|
||||
$(body)
|
||||
.find(".completed-percent")
|
||||
.html("(" + completed_percent + ")");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
@ -36,6 +36,8 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
|
||||
if (doc.docstatus==1) {
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
}
|
||||
|
||||
if(doc.docstatus==0 && !doc.__islocal) {
|
||||
|
@ -33,6 +33,9 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
this.make_purchase_invoice);
|
||||
}
|
||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
}
|
||||
|
||||
cur_frm.add_custom_button(wn._('From Purchase Order'),
|
||||
@ -68,6 +71,10 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
var item = wn.model.get_doc(cdt, cdn);
|
||||
wn.model.round_floats_in(item, ["qty", "received_qty"]);
|
||||
|
||||
if(!(item.received_qty || item.rejected_qty) && item.qty) {
|
||||
item.received_qty = item.qty;
|
||||
}
|
||||
|
||||
if(item.qty > item.received_qty) {
|
||||
msgprint(wn._("Error") + ": " + wn._(wn.meta.get_label(item.doctype, "qty", item.name))
|
||||
+ " > " + wn._(wn.meta.get_label(item.doctype, "received_qty", item.name)));
|
||||
|
@ -25,8 +25,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
set_default_account: function() {
|
||||
var me = this;
|
||||
|
||||
if (sys_defaults.auto_inventory_accounting && !this.frm.doc.expense_adjustment_account) {
|
||||
if (this.frm.doc.purpose == "Sales Return")
|
||||
if (cint(wn.defaults.get_default("auto_inventory_accounting")) && !this.frm.doc.expense_adjustment_account) {
|
||||
if (this.frm.doc.purpose == "Sales Return")
|
||||
account_for = "stock_in_hand_account";
|
||||
else if (this.frm.doc.purpose == "Purchase Return")
|
||||
account_for = "stock_received_but_not_billed";
|
||||
@ -78,7 +78,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
}
|
||||
};
|
||||
|
||||
if (sys_defaults.auto_inventory_accounting) {
|
||||
if(cint(wn.defaults.get_default("auto_inventory_accounting"))) {
|
||||
this.frm.add_fetch("company", "stock_adjustment_account", "expense_adjustment_account");
|
||||
|
||||
this.frm.fields_dict["expense_adjustment_account"].get_query = function() {
|
||||
@ -105,11 +105,8 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
erpnext.hide_naming_series();
|
||||
this.toggle_related_fields(this.frm.doc);
|
||||
this.toggle_enable_bom();
|
||||
if (this.frm.doc.docstatus==1) {
|
||||
this.show_stock_ledger();
|
||||
if(wn.boot.auto_inventory_accounting)
|
||||
this.show_general_ledger();
|
||||
}
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
|
||||
if(this.frm.doc.docstatus === 1 &&
|
||||
wn.boot.profile.can_create.indexOf("Journal Voucher")!==-1) {
|
||||
|
@ -68,6 +68,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
|
||||
} else if(this.frm.doc.docstatus == 1) {
|
||||
this.frm.set_intro("Cancelling this Stock Reconciliation will nullify its effect.");
|
||||
this.show_stock_ledger();
|
||||
this.show_general_ledger();
|
||||
} else {
|
||||
this.frm.set_intro("");
|
||||
}
|
||||
|
@ -26,13 +26,13 @@ erpnext.support.CustomerIssue = wn.ui.form.Controller.extend({
|
||||
customer: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.customer) {
|
||||
// TODO shift this to depends_on
|
||||
unhide_field(['customer_address', 'contact_person']);
|
||||
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "set_customer_defaults",
|
||||
});
|
||||
|
||||
// TODO shift this to depends_on
|
||||
unhide_field(['customer_address', 'contact_person']);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -62,13 +62,13 @@ erpnext.support.MaintenanceVisit = wn.ui.form.Controller.extend({
|
||||
customer: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.customer) {
|
||||
// TODO shift this to depends_on
|
||||
cur_frm.cscript.hide_contact_info();
|
||||
|
||||
return this.frm.call({
|
||||
doc: this.frm.doc,
|
||||
method: "set_customer_defaults",
|
||||
});
|
||||
|
||||
// TODO shift this to depends_on
|
||||
cur_frm.cscript.hide_contact_info();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -18,7 +18,7 @@ $(document).ready(function() {
|
||||
var item_code = $('[itemscope] [itemprop="name"]').text().trim();
|
||||
var qty = 0;
|
||||
|
||||
return wn.call({
|
||||
wn.call({
|
||||
type: "POST",
|
||||
method: "website.helpers.product.get_product_info",
|
||||
args: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user