mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
Merge pull request #34 from itsdave-de/33-improve-location-doctype
Location Doctype: Add link to IT Objects List with filter
This commit is contained in:
commit
693cf9db47
@ -39,6 +39,8 @@ jenv = {
|
|||||||
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
|
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
|
||||||
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
|
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
|
||||||
|
|
||||||
|
doctype_js = {"Location" : "public/js/location.js"}
|
||||||
|
|
||||||
# Home Pages
|
# Home Pages
|
||||||
# ----------
|
# ----------
|
||||||
|
|
||||||
@ -133,3 +135,6 @@ doc_events = {
|
|||||||
# "Task": "msp.task.get_dashboard_data"
|
# "Task": "msp.task.get_dashboard_data"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
override_doctype_class = {
|
||||||
|
"Location": "msp.overrides.location.CustomLocation.CustomLocation"
|
||||||
|
}
|
||||||
|
18
msp/overrides/location/CustomLocation.py
Normal file
18
msp/overrides/location/CustomLocation.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import frappe
|
||||||
|
from erpnext.assets.doctype.location.location import Location
|
||||||
|
|
||||||
|
class CustomLocation(Location):
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_all_child_locations_from_location(self):
|
||||||
|
parent_location_name = self.name
|
||||||
|
locations_to_filter = []
|
||||||
|
return self.search_child_locations(locations_to_filter, parent_location_name)
|
||||||
|
|
||||||
|
def search_child_locations(self, locations_to_filter, parent_location_name):
|
||||||
|
locations_to_filter.append(parent_location_name)
|
||||||
|
child_locations = frappe.db.get_list('Location', {'parent_location': parent_location_name}, ['name'])
|
||||||
|
if child_locations:
|
||||||
|
for child_location in child_locations:
|
||||||
|
self.search_child_locations(locations_to_filter, child_location['name'])
|
||||||
|
|
||||||
|
return locations_to_filter
|
0
msp/overrides/location/__init__.py
Normal file
0
msp/overrides/location/__init__.py
Normal file
10
msp/public/js/location.js
Normal file
10
msp/public/js/location.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
frappe.ui.form.on('Location', {
|
||||||
|
refresh(frm) {
|
||||||
|
frm.add_custom_button('Show IT Objects in Location', () => {
|
||||||
|
frm.call('get_all_child_locations_from_location',{})
|
||||||
|
.then((response) => {
|
||||||
|
frappe.set_route('List', 'IT Object', { location: ['in', `${response.message.toString()}`] })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user