Warehouse query filtered by company
This commit is contained in:
@@ -4,6 +4,37 @@
|
||||
frappe.provide("erpnext.stock");
|
||||
|
||||
erpnext.stock.StockController = frappe.ui.form.Controller.extend({
|
||||
onload: function() {
|
||||
// warehouse query if company
|
||||
if (this.frm.fields_dict.company) {
|
||||
this.setup_warehouse_query();
|
||||
}
|
||||
},
|
||||
|
||||
setup_warehouse_query: function() {
|
||||
var me = this;
|
||||
|
||||
var _set_warehouse_query = function(doctype, parentfield) {
|
||||
var warehouse_link_fields = frappe.meta.get_docfields(doctype, me.frm.doc.name,
|
||||
{"fieldtype": "Link", "options": "Warehouse"});
|
||||
$.each(warehouse_link_fields, function(i, df) {
|
||||
me.frm.set_query(df.fieldname, parentfield, function() {
|
||||
return erpnext.queries.warehouse(me.frm.doc);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
_set_warehouse_query(me.frm.doc.doctype);
|
||||
|
||||
// warehouse field in tables
|
||||
var table_fields = frappe.meta.get_docfields(me.frm.doc.doctype, me.frm.doc.name,
|
||||
{"fieldtype": "Table"});
|
||||
|
||||
$.each(table_fields, function(i, df) {
|
||||
_set_warehouse_query(df.options, df.fieldname);
|
||||
});
|
||||
},
|
||||
|
||||
show_stock_ledger: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.docstatus===1) {
|
||||
@@ -17,12 +48,12 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
|
||||
frappe.set_route("query-report", "Stock Ledger");
|
||||
}, "icon-bar-chart");
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
show_general_ledger: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.docstatus===1 && cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
if(this.frm.doc.docstatus===1 && cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
cur_frm.appframe.add_button(__('Accounting Ledger'), function() {
|
||||
frappe.route_options = {
|
||||
voucher_no: me.frm.doc.name,
|
||||
@@ -46,4 +77,4 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
|
||||
}
|
||||
refresh_field(this.frm.cscript.fname);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user