Merge pull request #1842 from anandpdoshi/anand-wip

Warehouse query filtered by Company, Fixed Gantt Chart query for task
This commit is contained in:
Rushabh Mehta 2014-06-25 10:18:35 +05:30
commit aa1edfb6ae
5 changed files with 44 additions and 4 deletions

View File

@ -254,3 +254,4 @@ def get_account_list(doctype, txt, searchfield, start, page_len, filters):
return frappe.widgets.reportview.execute("Account", filters = filter_list,
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)

View File

@ -52,7 +52,7 @@ def get_events(start, end, filters=None):
frappe.msgprint(_("No Permission"), raise_exception=1)
conditions = build_match_conditions("Task")
conditions and (" and " + conditions) or ""
conditions = conditions and (" and " + conditions) or ""
if filters:
filters = json.loads(filters)

View File

@ -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);
}
});
});

View File

@ -67,5 +67,11 @@ $.extend(erpnext.queries, {
employee: function() {
return { query: "erpnext.controllers.queries.employee_query" }
},
warehouse: function(doc) {
return {
filters: [["Warehouse", "company", "in", ["", doc.company]]]
}
}
});

View File

@ -7,6 +7,8 @@ frappe.require("assets/erpnext/js/controllers/stock_controller.js");
erpnext.TransactionController = erpnext.stock.StockController.extend({
onload: function() {
var me = this;
this._super();
if(this.frm.doc.__islocal) {
var today = get_today(),
currency = frappe.defaults.get_user_default("currency");