-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a36174a
commit c704ad8
Showing
1 changed file
with
64 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,105 @@ | ||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors | ||
// License: GNU General Public License v3. See license.txt | ||
|
||
|
||
frappe.ui.form.on("Warehouse", { | ||
onload: function(frm) { | ||
frm.set_query("default_in_transit_warehouse", function() { | ||
onload: function (frm) { | ||
frm.set_query("default_in_transit_warehouse", function () { | ||
return { | ||
filters:{ | ||
'warehouse_type' : 'Transit', | ||
'is_group': 0, | ||
'company': frm.doc.company | ||
} | ||
filters: { | ||
warehouse_type: "Transit", | ||
is_group: 0, | ||
company: frm.doc.company, | ||
}, | ||
}; | ||
}); | ||
}, | ||
|
||
refresh: function(frm) { | ||
frm.toggle_display('warehouse_name', frm.doc.__islocal); | ||
frm.toggle_display(['address_html','contact_html'], !frm.doc.__islocal); | ||
refresh: function (frm) { | ||
frm.toggle_display("warehouse_name", frm.doc.__islocal); | ||
frm.toggle_display( | ||
["address_html", "contact_html"], | ||
!frm.doc.__islocal | ||
); | ||
|
||
|
||
if(!frm.doc.__islocal) { | ||
if (!frm.doc.__islocal) { | ||
frappe.contacts.render_address_and_contact(frm); | ||
|
||
} else { | ||
frappe.contacts.clear_address_and_contact(frm); | ||
} | ||
|
||
frm.add_custom_button(__("Stock Balance"), function() { | ||
frappe.set_route("query-report", "Stock Balance", {"warehouse": frm.doc.name}); | ||
frm.add_custom_button(__("Stock Balance"), function () { | ||
frappe.set_route("query-report", "Stock Balance", { | ||
warehouse: frm.doc.name, | ||
}); | ||
}); | ||
|
||
if (cint(frm.doc.is_group) == 1) { | ||
frm.add_custom_button(__('Group to Non-Group'), | ||
function() { convert_to_group_or_ledger(frm); }, 'fa fa-retweet', 'btn-default') | ||
frm.add_custom_button( | ||
__("Group to Non-Group"), | ||
function () { | ||
convert_to_group_or_ledger(frm); | ||
}, | ||
"fa fa-retweet", | ||
"btn-default" | ||
); | ||
} else if (cint(frm.doc.is_group) == 0) { | ||
if(frm.doc.__onload && frm.doc.__onload.account) { | ||
frm.add_custom_button(__("General Ledger"), function() { | ||
if (frm.doc.__onload && frm.doc.__onload.account) { | ||
frm.add_custom_button(__("General Ledger"), function () { | ||
frappe.route_options = { | ||
"account": frm.doc.__onload.account, | ||
"company": frm.doc.company | ||
} | ||
account: frm.doc.__onload.account, | ||
company: frm.doc.company, | ||
}; | ||
frappe.set_route("query-report", "General Ledger"); | ||
}); | ||
} | ||
|
||
frm.add_custom_button(__('Non-Group to Group'), | ||
function() { convert_to_group_or_ledger(frm); }, 'fa fa-retweet', 'btn-default') | ||
frm.add_custom_button( | ||
__("Non-Group to Group"), | ||
function () { | ||
convert_to_group_or_ledger(frm); | ||
}, | ||
"fa fa-retweet", | ||
"btn-default" | ||
); | ||
} | ||
|
||
frm.toggle_enable(['is_group', 'company'], false); | ||
frm.toggle_enable(["is_group", "company"], false); | ||
|
||
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Warehouse'}; | ||
frappe.dynamic_link = { | ||
doc: frm.doc, | ||
fieldname: "name", | ||
doctype: "Warehouse", | ||
}; | ||
|
||
frm.fields_dict['parent_warehouse'].get_query = function(doc) { | ||
frm.fields_dict["parent_warehouse"].get_query = function (doc) { | ||
return { | ||
filters: { | ||
"is_group": 1, | ||
} | ||
} | ||
} | ||
is_group: 1, | ||
}, | ||
}; | ||
}; | ||
|
||
frm.fields_dict['account'].get_query = function(doc) { | ||
frm.fields_dict["account"].get_query = function (doc) { | ||
return { | ||
filters: { | ||
"is_group": 0, | ||
"account_type": "Stock", | ||
"company": frm.doc.company | ||
} | ||
} | ||
} | ||
} | ||
is_group: 0, | ||
account_type: "Stock", | ||
company: frm.doc.company, | ||
}, | ||
}; | ||
}; | ||
}, | ||
}); | ||
|
||
function convert_to_group_or_ledger(frm){ | ||
function convert_to_group_or_ledger(frm) { | ||
frappe.call({ | ||
method:"erpnext.stock.doctype.warehouse.warehouse.convert_to_group_or_ledger", | ||
method: "erpnext.stock.doctype.warehouse.warehouse.convert_to_group_or_ledger", | ||
args: { | ||
docname: frm.doc.name, | ||
is_group: frm.doc.is_group | ||
is_group: frm.doc.is_group, | ||
}, | ||
callback: function(){ | ||
callback: function () { | ||
frm.refresh(); | ||
} | ||
|
||
}) | ||
}, | ||
}); | ||
} |